package com.sgb.kjwl.view.ui.activity.self.publish;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputType;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.sdk.android.vod.upload.VODUploadCallback;
import com.alibaba.sdk.android.vod.upload.VODUploadClient;
import com.alibaba.sdk.android.vod.upload.VODUploadClientImpl;
import com.alibaba.sdk.android.vod.upload.model.UploadFileInfo;
import com.alibaba.sdk.android.vod.upload.model.VodInfo;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.blankj.utilcode.util.ColorUtils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityGoodsPublishBinding;
import com.sgb.kjwl.di.self.DaggerSelfComponent;
import com.sgb.kjwl.di.self.SelfModule;
import com.sgb.kjwl.model.entity.AddLayoutEntity;
import com.sgb.kjwl.model.entity.AlbumEntity;
import com.swgk.core.view.entity.AliProofEntity;
import com.sgb.kjwl.model.entity.ArrEntity;
import com.swgk.core.view.entity.AttrChildEntity;
import com.sgb.link.entity.BrandEntity;
import com.sgb.jicai.entity.FilterEntity;
import com.swgk.core.view.entity.GoodsPublishEntity;
import com.swgk.core.view.entity.GoodsPublishInfoEntity;
import com.swgk.core.view.entity.GoodsPublishSkuListEntity;
import com.swgk.core.view.entity.GoodsServicesEntity;
import com.swgk.core.view.entity.MenuEntity;
import com.swgk.core.view.entity.OtherInfo;
import com.sgb.kjwl.model.entity.ProvinceEntity;
import com.sgb.link.entity.PublicTypeEntity;
import com.sgb.kjwl.model.entity.STArrEntity;
import com.sgb.kjwl.model.entity.STPublishEntity;
import com.sgb.kjwl.model.entity.StrengthEntity;
import com.sgb.kjwl.model.entity.business.StorageManEntity;
import com.swgk.core.view.entity.VideoChangeEntity;
import com.sgb.kjwl.model.entity.self.VideoEntity;
import com.sgb.kjwl.model.entity.user.GetSkuEntity1;
import com.sgb.kjwl.model.entity.user.UnitEntity;
import com.sgb.kjwl.utils.GlideEngine;
import com.sgb.kjwl.utils.UtilSelectUtils;
import com.swgk.core.event.EventConstant;
import com.sgb.link.event.MaterialEvent;
import com.sgb.kjwl.view.event.self.GoodsEvent;
import com.sgb.kjwl.view.event.self.GoodsSkuEvent;
import com.sgb.kjwl.view.ui.adapter.self.publish.AdmixtureAdapter;
import com.sgb.kjwl.view.ui.adapter.self.publish.ArrAdapter;
import com.sgb.kjwl.view.ui.adapter.self.publish.ImageAdapter;
import com.sgb.kjwl.view.ui.adapter.self.publish.StrengthGradeAdapter;
import com.sgb.kjwl.view.ui.adapter.self.publish.VideoAdapter;
import com.sgb.kjwl.view.widget.BrandPopWindow;
import com.swgk.core.dialog.RoundDialog;
import com.swgk.core.dialog.UploadVideoDialog;
import com.swgk.core.util.DensityUtils;
import com.swgk.core.view.CityPickBuilder;
import com.swgk.core.view.CityPickView;
import com.sgb.kjwl.view.widget.FuturesPopWindow;
import com.swgk.core.view.pop.GoodsTypePopWindow;
import com.swgk.core.dialog.RoundCornerDialog;
import com.sgb.kjwl.view.widget.SelectAlbumPopWindow;
import com.sgb.kjwl.view.widget.StoragePopWindow;
import com.sgb.kjwl.view.widget.UnitPopWindow;
import com.sgb.kjwl.view.widget.VideoSelectPopWindow;
import com.sgb.kjwl.viewmodel.self.publish.GoodsPublishModel;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.customview.ItemInputTextView;
import com.swgk.core.customview.TextAreaEditView;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.util.MLog;
import com.swgk.core.util.MToast;
import com.swgk.core.util.SharedPreferenceUtil;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import javax.inject.Inject;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

import static com.swgk.core.util.UiUtil.post;
import static com.swgk.core.event.EventConstant.EVENT_BRAND_ADD;
import static com.swgk.core.event.EventConstant.EVENT_GOODS_PUBLISH;
import static com.swgk.core.event.EventConstant.EVENT_SELECT_ARR;
import static com.swgk.core.event.EventConstant.EVENT_SPEC_PRICE;
import static com.swgk.core.event.EventConstant.EVENT_STORAGE_ADD;

public class GoodsPublishActivity extends AppActivity implements ItemInputTextView.OnWholeItemClickListener {
    private Thread thread;
    private static final int MSG_LOAD_FAILED = 0x0003;
    private static final int MSG_LOAD_DATA_ARR = 0x0004;
    private static final int MSG_LOAD_SUCCESS_ARR = 0x0005;
    private boolean isLoadedArr = false;
    private ActivityGoodsPublishBinding binding;

    public static final int VIDEO_ADAPTER_LIST = 119110;
    public static final int IMAGE_ADAPTER_LIST = 110119;
    private int mImageAdapterPosition;
    private int mVideoAdapterPosition;
    //其他数据
    private List<AddLayoutEntity<List<AddLayoutEntity>>> addLayoutEntityList;

    private Map<Integer, List<LocalMedia>> mPImgSelectList = new HashMap();
    private Map<Integer, ImageAdapter> mPImgAdapter = new HashMap();
    private Map<Integer, ItemInputTextView> mPItv = new HashMap();
    private Map<Integer, TextAreaEditView> mPTae = new HashMap();
    private Map<Integer, List<String>> mPUpUrl = new HashMap();
    private Map<Integer, Integer> mPImageCount = new HashMap();
    private Map<Integer, Integer> mPCurrentImgNum = new HashMap();

    //多视频
    private Map<Integer, List<LocalMedia>> mPVideoSelectList = new HashMap();
    private Map<Integer, VideoAdapter> mPVideoAdapter = new HashMap();
    private Map<Integer, Integer> mPVideoIndex = new HashMap();
    private Map<Integer, List<File>> mPVideoFile = new HashMap();

    private boolean isVideoS;
    //图片上传
    private List<LocalMedia> selectList = new ArrayList<>();
    private List<String> editUrlsList = null;
    private ImageAdapter adapter;
    private VideoAdapter videoAdapter;
    private List<String> urls;
    private List<File> fileList;
    private List<VideoEntity> urlsVideo;
    private List<File> fileVideoList;
    private List<LocalMedia> locVideoList;
    private List<LocalMedia> adapterLocVideoList;
    public int imgTotal;
    private int currentImgNum;
    private List<String> uploadImgList = new ArrayList<>();
    //视频
    private SensorManager sensorManager;
    private SensorEventListener sensorEventListener;
    //上传视频
    private VODUploadClient uploader;
    //上传凭证
    private AliProofEntity aliInfo;
    private int arrPosition;

    private List<PublicTypeEntity<List<PublicTypeEntity>>> publicTypeEntityList;
    private List<FilterEntity<List<FilterEntity>>> attrList;
    private List<UnitEntity> unitEntityList;
    //仓储列表
    private List<StorageManEntity> storageManEntityList;
    //品牌列表
    private List<BrandEntity> brandEntityList;
    //属性子列表
    private List<ArrEntity.ChildType> childTypeList;
    //属性列表
    private List<ArrEntity> arrEntityList;
    //分类列表
    private List<MenuEntity<MenuEntity<MenuEntity>>> goodsTypeEntityList;
    //出售地区
    private List<ProvinceEntity<List<ProvinceEntity>>> parentAreaEntities;
    //商品发布要上传的属性列表
    private List<AttrChildEntity> attrChildEntityList;
    //强度等级和外加剂
    private List<STArrEntity> strength;
    private Map map;
    //视频弹窗
    private VideoSelectPopWindow videoSelectPopWindow;
    //视频列表弹窗
    private VideoSelectPopWindow videoListSelectPopWindow;
    //仓储弹窗
    private StoragePopWindow storagePopWindow;
    //品牌弹窗
    private BrandPopWindow brandPopWindow;
    //单位弹窗
    private UnitPopWindow unitPopWindow;
    //货期弹窗
    private FuturesPopWindow futuresPopWindow;
    //商品分类弹窗
    private GoodsTypePopWindow goodsTypePopWindow;
    //相册选择弹窗
    private SelectAlbumPopWindow selectAlbumPopWindow;
    //仓储搜索内容
    private String search = "";
    //品牌搜索内容
    private String brandSearch = "";
    //单位搜索内容
    private String unitSearch = "";
    //商品分类ID
    private String cId3 = "";
    //商品分类名称
    private String cName3 = "";
    //属性 ArrAdapter
    private ArrAdapter arrAdapter;
    //强度等级 adapter
    private StrengthGradeAdapter strengthGradeAdapter;
    //填写了的强度等级
    private List<StrengthEntity> strengthEntityList;
    //外加剂 adapter
    private AdmixtureAdapter admixtureAdapter;
    //填写了的外加剂
    private List<StrengthEntity> wjjList;
    //属性是否都已经选择
    private boolean isSelect = false;
    //商品分类是否再次选择
    private boolean typeSelect = false;
    //拼接属性名称
//    private String attrs = "";
    //详情id
    private String id;
    //是否重置属性
    private boolean isReset;
    //没选择的属性名称
    private String arrName;
    //被选中城市的下标
    private int cityPosition;
    //是否是商砼
    private boolean isST;
    private List<GetSkuEntity1> getSkuEntities;
    private List<GoodsPublishSkuListEntity> combination = new ArrayList<>();
    //相册列表
    private List<AlbumEntity> albumEntityList;
    //cNmae3是否发生变化
    private boolean cName3IsChange = false;
    // 视频List
    private List<VideoEntity> listVideo;
    //视频下标
    private int indexVideo = 0;

    private boolean IS_START_PUBLISH = true;//跳转类型用于判断是否是发布

    private boolean isSelectDay = true, isSelectLeft;//用于回显期货弹框数据：是否选择天，是否是现货
    private String dataText = "";//显示时间
    @Inject
    GoodsPublishModel viewModel;
    private boolean islooks;

    List<GoodsServicesEntity> listService;

    UploadVideoDialog uploadVideoDialog;

    public static void start(Context context) {
        start(context, null, false);
    }

    public static void start(Context context, String id, boolean isST) {
        Intent intent = new Intent(context, GoodsPublishActivity.class);
        intent.putExtra("id", id);
        intent.putExtra("isST", isST);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        context.startActivity(intent);
    }

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerSelfComponent.builder()
                .appComponent(appComponent)
                .selfModule(new SelfModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EventBus.getDefault().register(this);
    }

    // TODO: 2020/10/30 视频播放调用地方 
    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(GoodsPublishActivity.this, R.layout.activity_goods_publish);
        binding.setViewModel(viewModel);
        binding.backView.setOnClickListener(this);
        binding.nextView.setOnClickListener(this);
        binding.tvChip.setOnWholeItemClickListener(this);
        binding.etTitleLook.setOnClickListener(this);
        binding.deleteTv.setOnClickListener(this);
        binding.itemTvArr.setOnWholeItemClickListener(this);
        binding.itemTvStorage.setOnWholeItemClickListener(this);
        binding.itemTvUnit.setOnWholeItemClickListener(this);
        binding.itemTvFutures.setOnWholeItemClickListener(this);
        binding.itemTvBrand.setOnWholeItemClickListener(this);
        binding.itemTvArea.setOnWholeItemClickListener(this);
        binding.itemTvSpec.setOnWholeItemClickListener(this);
        binding.tvTitleClick.setOnClickListener(this);
//        binding.itemTvTax.setInputType(InputType.TYPE_CLASS_NUMBER);
        binding.itemBuyLow.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvBsprice.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvLeavePrice.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvTax.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvTax.setNumberAndLetter("0123456789");
        binding.itemTvBsprice.setCheck(4, 2);
        binding.itemTvPrice.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        binding.itemTvLeavePrice.setCheck(4, 2);
        binding.itemTvTax.setCheck(2, 2);
        adapter = new ImageAdapter(this, null, null, 8, 1);
        binding.recyclerView.setLayoutManager(new
                GridLayoutManager(GoodsPublishActivity.this, 4));
        binding.recyclerView.setAdapter(adapter);
        adapter.OnSelectPop(new ImageAdapter.ISelectPop() {
            @Override
            public void openPop() {
                if ("".equals(viewModel.goodsPublishEntity.get().getCid3())) {
                    showAlbumPop();
                } else {
                    String cid3 = viewModel.goodsPublishEntity.get().getCid3();
                    if (isST) {
                        // 2021-08-26 商砼目前只有一个，且商砼详情获取里没有返回cid3字段，经与后端讨论，Android/ios前端写死15
                        cid3 = "15";
                    }
                    if (albumEntityList == null) {
                        viewModel.getSupplierAlbumByCName(cid3);
                    } else {
                        if (cName3IsChange) {
                            viewModel.getSupplierAlbumByCName(cid3);
                        } else {
                            showAlbumPop();
                        }
                    }
                }
            }
        });
        videoAdapter = new
                VideoAdapter(this, null, null, 5);
        binding.recyclerViewVideo.setLayoutManager(new
                GridLayoutManager(GoodsPublishActivity.this, 4));
        binding.recyclerViewVideo.setAdapter(videoAdapter);
        videoAdapter.OnSelectPop(new VideoAdapter.ISelectPop() {
            @Override
            public void openPop(int index) {
                if (videoAdapter.getUrls().size() != 5) {
                    indexVideo = index;
                    //重置弹窗数据
                    videoSelectPopWindow.setDataRest(PictureConfig.TYPE_VIDEO);
                    videoSelectPopWindow.showDownPopwindow(binding.grayLayout, true);
                } else {
                    Toast.makeText(GoodsPublishActivity.this, "最多选择五个视频", Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void openVideo(VideoEntity data) {
                binding.videoView.setUp(data.getUrl(), JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, data.getTitle());
                binding.rlVideo.setVisibility(View.VISIBLE);
            }
        });
        binding.nS.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);

        getWindow().

                setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        binding.nS.setFocusable(true);
        binding.nS.setFocusableInTouchMode(true);
        binding.nS.setOnTouchListener((v, event) -> {
            v.requestFocusFromTouch();
            return false;
        });
        //-----------------------------------------------------------------------------------
        if (selectAlbumPopWindow == null) {
            selectAlbumPopWindow = new SelectAlbumPopWindow(GoodsPublishActivity.this);
        }
        selectAlbumPopWindow.setBgView(binding.grayLayout);
        selectAlbumPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                int type = (int) key1;
                if (type == 0) {
                    adapter.openAlbum();
                } else {
                    int canSelect = 8 - adapter.getUrls().size();
                    List<String> netUrl = new ArrayList<>();
                    for (int i = 0; i < adapter.getNetUrls().size(); i++) {
                        netUrl.add(adapter.getNetUrls().get(i));
                    }
                    EventBus.getDefault().postSticky(MaterialEvent.make().setMessageTag(EventConstant.EVENT_GOODS_NET_IMG_SELECT_RE).setMessageData(netUrl).setObject(canSelect));
                }
            }
        });
        //-----------------------------------------------------------------------------------
        if (futuresPopWindow == null) {
            futuresPopWindow = new FuturesPopWindow(GoodsPublishActivity.this);
        }
        futuresPopWindow.setBgView(binding.grayLayout);
        futuresPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                if (TextUtils.isEmpty(key1.toString())) {
                    binding.itemTvFutures.setContent("");
                    viewModel.goodsPublishEntity.get().setCommodityType(0);
                    viewModel.goodsPublishEntity.get().setDeliveryTimeUnit(0);
                } else {
                    if ((boolean) key2) {
                        binding.itemTvFutures.setContent(key1.toString());
                        viewModel.goodsPublishEntity.get().setCommodityType(1);
                        isSelectLeft = true;
                    } else {
                        isSelectLeft = false;
                        dataText = key1.toString();
                        viewModel.goodsPublishEntity.get().setCommodityType(2);
                        viewModel.goodsPublishEntity.get().setDeliveryTime(Long.valueOf(key1.toString()));
                        if ((boolean) key3) {
                            isSelectDay = true;
                            binding.itemTvFutures.setContent(key1.toString() + "日");
                            viewModel.goodsPublishEntity.get().setDeliveryTimeUnit(1);
                        } else {
                            isSelectDay = false;
                            viewModel.goodsPublishEntity.get().setDeliveryTimeUnit(2);
                            binding.itemTvFutures.setContent(key1.toString() + "个月");
                        }
                    }
                }
            }
        });

        //-----------------------------------------------------------------------------------
        if (goodsTypePopWindow == null) {
            goodsTypePopWindow = new GoodsTypePopWindow(GoodsPublishActivity.this);
        }
        goodsTypePopWindow.setBgView(binding.grayLayout);
        goodsTypePopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                GoodsPublishEntity goodsPublishEntity = (GoodsPublishEntity) key1;
                String st = (String) key2;
                if (!"商砼".equals(st)) {
                    binding.itemTvFutures.setVisibility(View.VISIBLE);
                    binding.itemBuyLow.setVisibility(View.VISIBLE);
                    isST = false;
                    goodsPublishEntity.getCid3();
                    if (!cId3.equals(goodsPublishEntity.getCid3())) {
                        typeSelect = true;
                        viewModel.getMaterChoose(goodsPublishEntity.getCid3());
                        viewModel.getServiceCategory(goodsPublishEntity.getCid3());
                        isReset = true;
                        binding.itemTvBrand.setContent("");
                        viewModel.goodsPublishEntity.get().setBrandId(null);
                        viewModel.getSku(goodsPublishEntity.getCid3());
                        viewModel.getAddLayout(goodsPublishEntity.getCid3());
                        cName3IsChange = true;
                        binding.itemTvSpec.setContent("");
                        combination.clear();
                    }
                    if (!TextUtils.isEmpty(viewModel.goodsPublishEntity.get().getName())) {
                        if (TextUtils.isEmpty(viewModel.goodsPublishEntity.get().getBrandName())) {
                            binding.etTitleLook.setText(viewModel.goodsPublishEntity.get().getName() + "/" + goodsPublishEntity.getCid3Name());
                        } else {
                            binding.etTitleLook.setText(viewModel.goodsPublishEntity.get().getName() + "/" +
                                    viewModel.goodsPublishEntity.get().getBrandName() + "/" + goodsPublishEntity.getCid3Name());
                        }
                    }
                } else {
                    if (!cId3.equals(goodsPublishEntity.getCid3())) {
                        viewModel.getAddLayout(goodsPublishEntity.getCid3());
                    }
                    isST = true;
                    viewModel.concreteAttrs(0);
                    viewModel.getServiceCategory(goodsPublishEntity.getCid3());
                    binding.itemTvFutures.setVisibility(View.GONE);
                    binding.itemBuyLow.setVisibility(View.GONE);
                    binding.llSpec.setVisibility(View.GONE);
                }
                cId3 = goodsPublishEntity.getCid3();
                if (goodsPublishEntity != null && goodsPublishEntity.getCid3Name() != null) {
                    cName3 = goodsPublishEntity.getCid3Name();
                }
                binding.itemTvArr.setContent(goodsPublishEntity.getCid1Name()
                        + "-" + goodsPublishEntity.getCid2Name()
                        + "-" + goodsPublishEntity.getCid3Name());
                viewModel.goodsPublishEntity.get().setCid1(goodsPublishEntity.getCid1());
                viewModel.goodsPublishEntity.get().setCid2(goodsPublishEntity.getCid2());
                viewModel.goodsPublishEntity.get().setCid3(goodsPublishEntity.getCid3());
                viewModel.goodsPublishEntity.get().setCid1Name(goodsPublishEntity.getCid1Name());
                viewModel.goodsPublishEntity.get().setCid2Name(goodsPublishEntity.getCid2Name());
                viewModel.goodsPublishEntity.get().setCid3Name(goodsPublishEntity.getCid3Name());
                setGoneAndDisplay();
            }
        });
        //-------------------------视频选择弹窗----------------------------------------------
        if (videoSelectPopWindow == null) {
            videoSelectPopWindow = new
                    VideoSelectPopWindow(GoodsPublishActivity.this);
        }
        videoSelectPopWindow.setBgView(binding.grayLayout);
        videoSelectPopWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        videoSelectPopWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        videoSelectPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                isVideoS = false;
                int status = (int) key1;
                indexVideo = (int) key3;
                VideoEntity videoEntity = (VideoEntity) key2;
                if (status == 1) {
                    videoAdapter.addUrls(videoEntity);
                    adapterLocVideoList.addAll(locVideoList);
                    for (LocalMedia localMedia : adapterLocVideoList) {
                        File file;
                        if (localMedia.getRealPath() == null) {
                            file = new File(localMedia.getPath());
                        } else {
                            file = new File(localMedia.getRealPath());
                        }
                        fileVideoList.add(file);
                    }
                    videoAdapter.setDatas(adapterLocVideoList, videoAdapter.getUrls());
                    videoAdapter.setFileList(fileVideoList);
                    addFileToAli(videoEntity.getTitle());
                    viewModel.getVideoParams();
                }
            }
        });
        //-------------------------视频列表选择弹窗----------------------------------------------
        if (videoListSelectPopWindow == null) {
            videoListSelectPopWindow = new
                    VideoSelectPopWindow(GoodsPublishActivity.this);
        }
        videoListSelectPopWindow.setBgView(binding.grayLayout);
        videoListSelectPopWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        videoListSelectPopWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        videoListSelectPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                isVideoS = true;
                int status = (int) key1;
                mPVideoIndex.put(mVideoAdapterPosition, (int) key3);
                VideoEntity videoEntity = (VideoEntity) key2;
                if (status == 1) {
                    mPVideoAdapter.get(mVideoAdapterPosition).addUrls(videoEntity);
                    adapterLocVideoList.addAll(mPVideoSelectList.get(mVideoAdapterPosition));
                    for (LocalMedia localMedia : adapterLocVideoList) {
                        File file;
                        if (localMedia.getRealPath() == null) {
                            file = new File(localMedia.getPath());
                        } else {
                            file = new File(localMedia.getRealPath());
                        }
                        mPVideoFile.get(mVideoAdapterPosition).add(file);
                    }
                    mPVideoAdapter.get(mVideoAdapterPosition).setDatas(adapterLocVideoList, mPVideoAdapter.get(mVideoAdapterPosition).getUrls());
                    mPVideoAdapter.get(mVideoAdapterPosition).setFileList(mPVideoFile.get(mVideoAdapterPosition));
                    addSomeFileToAli(videoEntity.getTitle());
                    viewModel.getVideoParams();
                }
            }
        });
        //-----------------------------------------------------------------------------------
        if (storagePopWindow == null) {
            storagePopWindow = new StoragePopWindow(GoodsPublishActivity.this);
        }
        storagePopWindow.setBgView(binding.grayLayout);
        storagePopWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        storagePopWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        storagePopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                StorageManEntity storageManEntity = (StorageManEntity) key1;
                if (storageManEntity == null)
                    return;
                //商品
                binding.itemTvStorage.setContent(storageManEntity.getStorageName());
                viewModel.goodsPublishEntity.get().setDepotNo(storageManEntity.getNo());
                viewModel.goodsPublishEntity.get().setProvinceNo(storageManEntity.getProvinceNo());
                viewModel.goodsPublishEntity.get().setCityNo(storageManEntity.getCityNo());
                viewModel.goodsPublishEntity.get().setDistrictNo(storageManEntity.getDistrictNo());
                //商砼
                viewModel.sTPublishEntity.get().setDepotNo(storageManEntity.getNo());
                viewModel.sTPublishEntity.get().setProvinceNo(storageManEntity.getProvinceNo());
                viewModel.sTPublishEntity.get().setCityNo(storageManEntity.getCityNo());
                viewModel.sTPublishEntity.get().setDistrictNo(storageManEntity.getDistrictNo());
            }
        });
        storagePopWindow.inputTextInterface(new StoragePopWindow.InputTextInterface() {
            @Override
            public void input(String s) {
                hideInput();
                search = s;
                viewModel.getStorageList(search, false);
            }
        });
        storagePopWindow.onLodMoreListen(new StoragePopWindow.ILodMore() {
            @Override
            public void onRefresh() {
                viewModel.getStorageList(search, false);
            }

            @Override
            public void onLoadMore() {
                viewModel.getStorageList(search, true);
            }
        });
        //-------------------------------------------------------------------------------------
        if (brandPopWindow == null) {
            brandPopWindow = new BrandPopWindow(GoodsPublishActivity.this, true);
        }
        brandPopWindow.setBgView(binding.grayLayout);
        brandPopWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        brandPopWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        brandPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                binding.itemTvBrand.setContent((String) key2);
                viewModel.goodsPublishEntity.get().setBrandId((String) key1);
                if (!TextUtils.isEmpty(viewModel.goodsPublishEntity.get().getName())) {
                    binding.etTitleLook.setText(viewModel.goodsPublishEntity.get().getName() + "/" +
                            viewModel.goodsPublishEntity.get().getBrandName() + "/" + viewModel.goodsPublishEntity.get().getCid3Name());
                }
            }
        });
        brandPopWindow.inputTextInterface(new BrandPopWindow.InputTextInterface() {
            @Override
            public void input(String s) {
                hideInput();
                brandSearch = s;
                viewModel.getBrandList(viewModel.goodsPublishEntity.get().getCid3(), brandSearch);
            }
        });
        //-------------------------------------------------------------------------------------
        if (unitPopWindow == null) {
            unitPopWindow = new UnitPopWindow(GoodsPublishActivity.this);
        }
        unitPopWindow.setBgView(binding.grayLayout);
        unitPopWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        unitPopWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
        unitPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                binding.itemBuyLow.setContent("");
                setBuyLow((String) key2, true);
                binding.itemTvUnit.setContent((String) key2);
            }
        });
        unitPopWindow.inputTextInterface(new UnitPopWindow.InputTextInterface() {
            @Override
            public void input(String s) {
                hideInput();
                unitSearch = s;
                viewModel.getUnitList(unitSearch);
            }
        });
        //------------------------------------------------------------------------------------
        if (arrAdapter == null) {
            arrAdapter = new ArrAdapter(GoodsPublishActivity.this, null);
        }
        binding.recyclerArr.setLayoutManager(new

                LinearLayoutManager(GoodsPublishActivity.this));
        binding.recyclerArr.setAdapter(arrAdapter);
        arrAdapter.OnClickArr(new ArrAdapter.ClickArr() {
            @Override
            public void clickArr(List<ArrEntity.ChildType> childType, int index, String pName, String
                    pId) {
                showArrPop(childType, index);
            }
        });
        if (strengthGradeAdapter == null) {
            strengthGradeAdapter = new StrengthGradeAdapter(GoodsPublishActivity.this, null);
        }
        binding.recyclerStrengthGrade.setLayoutManager(new

                LinearLayoutManager(GoodsPublishActivity.this));
        binding.recyclerStrengthGrade.setAdapter(strengthGradeAdapter);

        if (admixtureAdapter == null) {
            admixtureAdapter = new AdmixtureAdapter(GoodsPublishActivity.this, null);
        }
        binding.recyclerAdmixture.setLayoutManager(new

                LinearLayoutManager(GoodsPublishActivity.this));
        binding.recyclerAdmixture.setAdapter(admixtureAdapter);

        binding.etName.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (s.toString().contains(" ")) {
                    String[] str = s.toString().split(" ");
                    StringBuffer sb = new StringBuffer();
                    for (int i = 0; i < str.length; i++) {
                        sb.append(str[i]);
                    }
                    binding.etName.setText(sb.toString());
                    binding.etName.setSelection(start);
                }
                if (!isST) {
                    if (TextUtils.isEmpty(viewModel.goodsPublishEntity.get().getCid3Name())) {
                        binding.etTitleLook.setText(s);
                    } else {
                        if (TextUtils.isEmpty(viewModel.goodsPublishEntity.get().getBrandName())) {
                            binding.etTitleLook.setText(s + "/" + viewModel.goodsPublishEntity.get().getCid3Name());
                        } else {
                            binding.etTitleLook.setText(s + "/" +
                                    viewModel.goodsPublishEntity.get().getBrandName() + "/" + viewModel.goodsPublishEntity.get().getCid3Name());
                        }
                    }
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }

    @SuppressWarnings("unchecked")
    @Override
    protected void init() {
        id = getIntent().getStringExtra("id");
        isST = getIntent().getBooleanExtra("isST", false);
        if (id != null) {
            IS_START_PUBLISH = false;
            if (!isST) {
                viewModel.getNewGoodsById(id);
                viewModel.getGoodsOtherInfo(id);
            } else {
                viewModel.concretePublishDetail(id);
                viewModel.getStOtherInfo(id);
            }
        }
        fileList = new ArrayList<>();
        urls = new ArrayList<>();
        urlsVideo = new ArrayList<>();
        fileVideoList = new ArrayList<>();
        map = new HashMap();
        editUrlsList = new ArrayList<>();
        locVideoList = new ArrayList<>();
        adapterLocVideoList = new ArrayList<>();
        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        sensorEventListener = new JCVideoPlayer.JCAutoFullscreenListener();
        uploader = new VODUploadClientImpl(getApplicationContext());
    }

    VODUploadCallback callback = new VODUploadCallback() {
        @Override
        public void onUploadSucceed(UploadFileInfo info) {
            Log.e("onUploadSucceed", "onUploadSucceed");
            if (isVideoS) {
                mPVideoAdapter.get(mVideoAdapterPosition).getUrls().get(mPVideoIndex.get(mVideoAdapterPosition)).setVideoId(aliInfo.getVideoId());
            } else {
                videoAdapter.getUrls().get(indexVideo).setVideoId(aliInfo.getVideoId());
            }
            binding.nextView.setClickable(true);
            uploadVideoDialog.dismiss();
        }

        @Override
        public void onUploadFailed(UploadFileInfo info, String code, String message) {
            Log.e("onUploadFailed", "onUploadFailed");
            uploadVideoDialog.dismiss();
//            OSSLog.logError("onfailed ------------------ " + info.getFilePath() + " " + code + " " + message);
        }

        @Override
        public void onUploadProgress(UploadFileInfo info, long uploadedSize, long totalSize) {
            Log.e("onUploadFailed", "onUploadFailed");
//            OSSLog.logDebug("onProgress ------------------ " + info.getFilePath() + " " + uploadedSize + " " + totalSize);
        }

        @Override
        public void onUploadTokenExpired() {
            Log.e("onUploadTokenExpired", "onUploadTokenExpired");
//            OSSLog.logError("onExpired ------------- ");
            // 重新刷新上传凭证:RefreshUploadVideo
//            uploadAuth = "此处需要设置重新刷新凭证之后的值";
            uploader.resumeWithAuth(aliInfo.getUploadAuth());
        }

        @Override
        public void onUploadRetry(String code, String message) {
            Log.e("onUploadRetry", "onUploadRetry");
//            OSSLog.logError("onUploadRetry ------------- ");
        }

        @Override
        public void onUploadRetryResume() {
            Log.e("onUploadRetryResume", "onUploadRetryResume");
//            OSSLog.logError("onUploadRetryResume ------------- ");
        }

        @Override
        public void onUploadStarted(UploadFileInfo uploadFileInfo) {
            Log.e("onUploadStarted", "onUploadStarted");
//            OSSLog.logError("onUploadStarted ------------- ");
            uploader.setUploadAuthAndAddress(uploadFileInfo, aliInfo.getUploadAuth(), aliInfo.getUploadAddress());
            uploadVideoDialog = new UploadVideoDialog(GoodsPublishActivity.this, "视频上传中...");
            uploadVideoDialog.show();
        }
    };

    //数据回显
    public void setData() {
        setGoneAndDisplay();
        binding.itemTvArr.setContent(viewModel.goodsPublishEntity.get().getCid1Name() + "-" +
                viewModel.goodsPublishEntity.get().getCid2Name() + "-" +
                viewModel.goodsPublishEntity.get().getCid3Name());
        cName3 = viewModel.goodsPublishEntity.get().getCid3Name();
        adapter.setNetImgList(viewModel.goodsPublishEntity.get().getImageUrls());
        attrChildEntityList = viewModel.goodsPublishEntity.get().getAttrList();
        viewModel.getMaterChoose(viewModel.goodsPublishEntity.get().getCid3());
        /**
         * 商品类型 1：现货 2：期货
         */
        binding.itemTvFutures.setVisibility(View.VISIBLE);
        binding.itemBuyLow.setVisibility(View.VISIBLE);
        setBuyLow(viewModel.goodsPublishEntity.get().getUnit(), false);
        binding.itemBuyLow.setContent(viewModel.goodsPublishEntity.get().getLowestBuy());
        if ((viewModel.goodsPublishEntity.get().getCommodityType() == 1)) {
            binding.itemTvFutures.setContent("现货");
            isSelectLeft = true;
        } else if (viewModel.goodsPublishEntity.get().getCommodityType() == 2) {
            //货期时间 单位 1：天 2：月
            isSelectLeft = false;
            String s = viewModel.goodsPublishEntity.get().getDeliveryTimeUnit() == 1 ? viewModel.goodsPublishEntity.get().getDeliveryTime() + "天" : viewModel.goodsPublishEntity.get().getDeliveryTime() + "月";
            binding.itemTvFutures.setContent(s);
            dataText = viewModel.goodsPublishEntity.get().getDeliveryTime() + "";
            isSelectDay = viewModel.goodsPublishEntity.get().getDeliveryTimeUnit() == 1 ? true : false;
        } else {
            binding.itemTvFutures.setContent("");
        }
        //设置视频
        List<VideoEntity> videoEntities = new ArrayList<>();
        if (viewModel.goodsPublishEntity.get().getVideoList() != null)
            for (int i = 0; i < viewModel.goodsPublishEntity.get().getVideoList().size(); i++) {
                VideoEntity videoEntity = new VideoEntity();
                //视频类型
                videoEntity.setType(viewModel.goodsPublishEntity.get().getVideoList().get(i).getType());
                //视频id
                videoEntity.setVideoId(viewModel.goodsPublishEntity.get().getVideoList().get(i).getVideoId());
                //视频名称
                videoEntity.setTitle(viewModel.goodsPublishEntity.get().getVideoList().get(i).getVideoName());
                //视频地址
                videoEntity.setUrl(viewModel.goodsPublishEntity.get().getVideoList().get(i).getPlayUrl());
                //视频时长
                videoEntity.setTime(viewModel.goodsPublishEntity.get().getVideoList().get(i).getTime());
                videoEntities.add(videoEntity);
            }
        videoAdapter.setNetImgList(videoEntities);
        cId3 = viewModel.goodsPublishEntity.get().getCid3();
        binding.itemTvArea.setContent(viewModel.goodsPublishEntity.get().getSellProvinceName());
        editUrlsList.addAll(viewModel.goodsPublishEntity.get().getImageUrls());
        if (viewModel.goodsPublishEntity.get().getItemDetail() != null && !viewModel.goodsPublishEntity.get().getItemDetail().equals("")) {
            setHtml(viewModel.goodsPublishEntity.get().getItemDetail());
        }
        viewModel.getSku(viewModel.goodsPublishEntity.get().getCid3());
        if (viewModel.goodsPublishEntity.get().getSkuList() != null && viewModel.goodsPublishEntity.get().getSkuList().size() != 0) {
            binding.itemTvSpec.setContent("已填写");
        }
        if (viewModel.goodsPublishEntity.get().getItemServerAttrVals() != null && viewModel.goodsPublishEntity.get().getItemServerAttrVals().size() != 0) {
            listService = viewModel.goodsPublishEntity.get().getItemServerAttrVals();
            if (isHasChecked(listService)) {
                binding.tvChip.setContent("已填写");
            } else {
                binding.tvChip.setContent("");
            }
            binding.tvChip.setVisibility(View.VISIBLE);
        } else {
            binding.tvChip.setVisibility(View.GONE);
        }
        combination = viewModel.goodsPublishEntity.get().getSkuList();
        viewModel.goodsPublishEntity.get().setSkuOldList(combination);
    }

    private void setBuyLow(String key, boolean isChange) {
        if (UtilSelectUtils.isDouble3(key)) {
            binding.itemBuyLow.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
            binding.itemBuyLow.setCheck(6, 3, true);
            if (isChange) {
                binding.itemBuyLow.setContent("1.000");
            }
        } else {
            binding.itemBuyLow.setInputType(InputType.TYPE_CLASS_NUMBER);
            binding.itemBuyLow.setEditLength(6);
            if (isChange) {
                binding.itemBuyLow.setContent("1");
            }
        }
    }

    public void setStData() {
        setGoneAndDisplay();
        STPublishEntity stPublishEntity = viewModel.sTPublishEntity.get();
        binding.itemTvArea.setContent(stPublishEntity.getSellProvinceName());
        binding.itemTvArr.setContent("商砼-混凝土-混凝土");
        cName3 = "混凝土";
        binding.etName.setText(stPublishEntity.getTitle());
        binding.etMark.setText(stPublishEntity.getItemDesc());
        binding.itemTvStorage.setContent(stPublishEntity.getDepotName());
        binding.itemTvTax.setContent(stPublishEntity.getTax());
        viewModel.concreteAttrs(1);
        binding.itemTvFutures.setVisibility(View.GONE);
        binding.itemBuyLow.setVisibility(View.GONE);
        if (viewModel.sTPublishEntity.get().getItemServerAttrVals() != null && viewModel.sTPublishEntity.get().getItemServerAttrVals().size() != 0) {
            listService = viewModel.sTPublishEntity.get().getItemServerAttrVals();
            if (isHasChecked(listService)) {
                binding.tvChip.setContent("已填写");
            } else {
                binding.tvChip.setContent("");
            }
            binding.tvChip.setVisibility(View.VISIBLE);
        } else {
            binding.tvChip.setVisibility(View.GONE);
        }
        //设置视频
        List<VideoEntity> videoEntities = new ArrayList<>();
        if (viewModel.sTPublishEntity.get().getVideoList() != null) {
            for (int i = 0; i < viewModel.sTPublishEntity.get().getVideoList().size(); i++) {
                VideoEntity videoEntity = new VideoEntity();
                //视频类型
                videoEntity.setType(viewModel.sTPublishEntity.get().getVideoList().get(i).getType());
                //视频id
                videoEntity.setVideoId(viewModel.sTPublishEntity.get().getVideoList().get(i).getVideoId());
                //视频名称
                videoEntity.setTitle(viewModel.sTPublishEntity.get().getVideoList().get(i).getVideoName());
                //视频地址
                videoEntity.setUrl(viewModel.sTPublishEntity.get().getVideoList().get(i).getPlayUrl());
                //视频时长
                videoEntity.setTime(viewModel.sTPublishEntity.get().getVideoList().get(i).getTime());
                videoEntities.add(videoEntity);
            }
        }
        videoAdapter.setNetImgList(videoEntities);
        adapter.setNetImgList(stPublishEntity.getImageUrls());
        editUrlsList.addAll(stPublishEntity.getImageUrls());
        if (stPublishEntity.getItemDetail() != null && !"".equals(stPublishEntity.getItemDetail())) {
            setHtml(stPublishEntity.getItemDetail());
        }
    }


    //仓储popwindow
    public void showStoragePop(List<StorageManEntity> list, boolean isLodMore) {
        this.storageManEntityList = list;
        showStoragePop(isLodMore);
    }

    private void showStoragePop(boolean isLodMore) {
        if (!storagePopWindow.isShowing()) {
            storagePopWindow.showDownPopwindow(binding.grayLayout, true);
        }
        storagePopWindow.setData(storageManEntityList, isLodMore);
    }

    //品牌popWindow
    public void showBrandPop(List<BrandEntity> data) {
        this.brandEntityList = data;
        showBrandPop(true);
    }

    private void showBrandPop(boolean isUpdate) {
        if (!brandPopWindow.isShowing()) {
            brandPopWindow.showDownPopwindow(binding.grayLayout, true);
        }
        brandPopWindow.setData(brandEntityList, viewModel.goodsPublishEntity.get().getCid3(), isUpdate);
    }

    //单位popWindow
    public void showUnitPop(List<UnitEntity> data) {
        this.unitEntityList = data;
        showUnitPop(true);
    }

    private void showUnitPop(boolean isUpdate) {
        if (!unitPopWindow.isShowing()) {
            unitPopWindow.showDownPopwindow(binding.grayLayout, true);
        }
        unitPopWindow.setData(unitEntityList, isUpdate);
    }

    //商品分类popWindow
    public void showGoodsTypePop(List<MenuEntity<MenuEntity<MenuEntity>>> data) {
        this.goodsTypeEntityList = data;
        if (!goodsTypePopWindow.isShowing()) {
            goodsTypePopWindow.showDownPopwindow(binding.grayLayout, true);
        }
        goodsTypePopWindow.setData(goodsTypeEntityList);
    }

    private void showGoodsTypePop() {
        if (!goodsTypePopWindow.isShowing()) {
            goodsTypePopWindow.showDownPopwindow(binding.grayLayout, true);
        }
    }

    //动态设置属性列表
    public void setArrList(List<ArrEntity> data) {
        if (data != null && data.size() != 0) {
            binding.recyclerArr.setVisibility(View.VISIBLE);
//            binding.tvArr.setVisibility(View.VISIBLE);
            binding.itemTvFutures.setDeliverLineVG(false);
            this.arrEntityList = data;
            if (viewModel.goodsPublishEntity.get().getId() == null) {//新增时无ID，编辑时有ID
                newData(data);
                arrAdapter.setDatas(data);
            } else {
                if (isReset) {
                    newData(data);
                } else {
                    for (int i = 0; i < viewModel.goodsPublishEntity.get().getAttrList().size(); i++) { //编辑时走这里
                        for (int j = 0; j < data.size(); j++) {
                            if (data.get(j).getName().equals(viewModel.goodsPublishEntity.get().getAttrList().get(i).getAttrKey())) {
                                data.get(j).setContent(viewModel.goodsPublishEntity.get().getAttrList().get(i).getAttrValue());
                            }
                        }
                    }
                    //新建一个列表整合选中和未选中的属性
                    List<AttrChildEntity> attrTempList = new ArrayList<>();
                    for (int m = 0; m < data.size(); m++) {
                        AttrChildEntity attrChildEntity = new AttrChildEntity();
                        attrChildEntity.setAttrKey(data.get(m).getName());
                        attrChildEntity.setAttrKeyId(data.get(m).getId());
                        attrChildEntity.setIsfill(data.get(m).getIsfill());
                        attrTempList.add(attrChildEntity);
                    }

                    for (int n = 0; n < viewModel.goodsPublishEntity.get().getAttrList().size(); n++) {
                        for (int a = 0; a < attrTempList.size(); a++) {
                            if (attrTempList.get(a).getAttrKey().equals(viewModel.goodsPublishEntity.get().getAttrList().get(n).getAttrKey())) {
                                attrTempList.get(a).setAttrValue(viewModel.goodsPublishEntity.get().getAttrList().get(n).getAttrValue());
                                attrTempList.get(a).setAttrValueId(viewModel.goodsPublishEntity.get().getAttrList().get(n).getAttrValueId());
                            }
                        }
                    }
                    attrChildEntityList = attrTempList;
                }
                arrAdapter.setDatas(data);
                isReset = false;
            }
        } else {
//            binding.tvArr.setVisibility(View.GONE);
            binding.itemTvFutures.setDeliverLineVG(true);
            islooks = false;
            binding.recyclerArr.setVisibility(View.GONE);
        }
    }

    //注册地址
    public void showAddressPop(List<ProvinceEntity<List<ProvinceEntity>>> datas) {
        this.parentAreaEntities = datas;
        showCityPop();
    }

    //出售地区弹窗
    public void showCityPop() {
        //条件选择器
        CityPickView cityOption = new CityPickBuilder(GoodsPublishActivity.this, (options1, options2, options3, v) -> {
            String content = parentAreaEntities.get(options1).getAreaName();
            binding.itemTvArea.setContent(content);
            cityPosition = options1;
            //设置商砼发布的出售地区
            viewModel.sTPublishEntity.get().setSellProvinceNo(parentAreaEntities.get(options1).getId() + "");
            viewModel.sTPublishEntity.get().setSellProvinceName(content);
            //设置商品发布的出售地区
            viewModel.goodsPublishEntity.get().setSellProvinceNo(parentAreaEntities.get(options1).getId() + "");
        }).build();
        cityOption.setPicker(parentAreaEntities);
        cityOption.setSelectOptions(cityPosition);
        cityOption.setTitleText("出售地区");
        cityOption.show();
    }

    private void newData(List<ArrEntity> data) {
        arrAdapter.isReset(true);
        if (attrChildEntityList == null) {
            attrChildEntityList = new ArrayList<>();
        }
        attrChildEntityList.clear();
        if (data != null) {
            for (int i = 0; i < data.size(); i++) {
                AttrChildEntity attrChildEntity = new AttrChildEntity();
                attrChildEntity.setAttrKey(data.get(i).getName());
                attrChildEntity.setAttrKeyId(data.get(i).getId());
                attrChildEntity.setIsfill(data.get(i).getIsfill());
                attrChildEntityList.add(attrChildEntity);
            }
            viewModel.goodsPublishEntity.get().setAttrList(attrChildEntityList);
        }
    }

    //图片单张上传
    public void uploadRefresh(String url, int type) {
        uploadImgList.add(url);
        if (currentImgNum + 1 == imgTotal) {
            uploadImgSuccess(uploadImgList, type);
        } else {
            currentImgNum++;
            viewModel.uploadMutiFileModel(adapter.getFileList().get(currentImgNum), 0, currentImgNum + 1);
        }
    }

    //图片上传成功回调
    public void uploadImgSuccess(List<String> urls, int type) {
        //拼接图片url
        List<String> urlList = new ArrayList<>();
        for (int i = 0; i < urls.size(); i++) {
            urlList.add(urls.get(i));
        }
        //编辑
        if (type == 0) {
            if (!isST) {
                editUrlsList.clear();
                editUrlsList.addAll(adapter.getNetUrls());
                //商品
                if (viewModel.goodsPublishEntity.get().getImageUrls() != null) {
                    viewModel.goodsPublishEntity.get().getImageUrls().clear();
                    viewModel.goodsPublishEntity.get().getImageUrls().addAll(editUrlsList);
                    viewModel.goodsPublishEntity.get().getImageUrls().addAll(urlList);
                    urlList.clear();
                    urlList.addAll(viewModel.goodsPublishEntity.get().getImageUrls());
                }
            } else {
                editUrlsList.clear();
                editUrlsList.addAll(adapter.getNetUrls());
                //商砼
                if (viewModel.sTPublishEntity.get().getImageUrls() != null) {
                    viewModel.sTPublishEntity.get().getImageUrls().clear();
                    viewModel.sTPublishEntity.get().getImageUrls().addAll(editUrlsList);
                    viewModel.sTPublishEntity.get().getImageUrls().addAll(urlList);
                    urlList.clear();
                    urlList.addAll(viewModel.sTPublishEntity.get().getImageUrls());
                }
            }
        }

        viewModel.goodsPublishEntity.get().setImageUrls(urlList);
        viewModel.sTPublishEntity.get().setImageUrls(urlList);
        List<VideoChangeEntity> list = new ArrayList<>();
        //视频实体转换
        if (videoAdapter.getUrls().size() != 0)
            for (int i = 0; i < videoAdapter.getUrls().size(); i++) {
                VideoChangeEntity entity = new VideoChangeEntity();
                entity.setVideoName(videoAdapter.getUrls().get(i).getTitle());
                entity.setVideoId(videoAdapter.getUrls().get(i).getVideoId());
                list.add(entity);
            }
        if (isST) {
            if (IS_START_PUBLISH) {
                viewModel.sTPublishEntity.get().setDraft(5);
            } else {
                viewModel.sTPublishEntity.get().setDraft(1);
            }
            if (list != null && list.size() > 0) {
                viewModel.sTPublishEntity.get().setVideoList(list);
                viewModel.sTPublishEntity.get().getVideoList().get(0).setType(1);
            } else {
                viewModel.sTPublishEntity.get().setVideoList(list);
            }
            viewModel.concretePublish();
        } else {
            //商品
            if (IS_START_PUBLISH) {
                viewModel.goodsPublishEntity.get().setStatus(5);
            } else {
                viewModel.goodsPublishEntity.get().setStatus(1);
            }
            if (list != null && list.size() > 0) {
                viewModel.goodsPublishEntity.get().setVideoList(list);
                viewModel.goodsPublishEntity.get().getVideoList().get(0).setType(1);
            } else {
                viewModel.goodsPublishEntity.get().setVideoList(list);
            }
            viewModel.goodsPublish();
        }
    }


    public void showArrPop(List<ArrEntity.ChildType> childTypeList, int index) {
        this.childTypeList = childTypeList;
        showArrPop(index);
    }

    private void showArrPop(int index) {
        OptionsPickerView businessOption = new OptionsPickerBuilder(GoodsPublishActivity.this, (options1, options2, options3, v) -> {
            String content = childTypeList.get(options1).getCname();
            arrAdapter.updateStatus(index, content);
            attrChildEntityList.get(index).setAttrValue(childTypeList.get(options1).getCname());
            attrChildEntityList.get(index).setAttrValueId(childTypeList.get(options1).getCid());
            map.put(index, options1);
        }).build();
        if (map.get(index) == null) {
            businessOption.setSelectOptions(arrPosition);
        } else {
            businessOption.setSelectOptions((Integer) map.get(index));
        }
        businessOption.setPicker(childTypeList);
        businessOption.setTitleText("选择属性值");
        businessOption.show();
    }

    //阿里凭证
    public void setAliInfo(AliProofEntity aliInfo) {
        binding.nextView.setClickable(false);
        this.aliInfo = aliInfo;
        uploader.init(callback);
        uploader.start();

    }

    //添加文件
    private void addFileToAli(String videoName) {
        VodInfo vodInfo = new VodInfo();
        vodInfo.setTitle(videoName);
        vodInfo.setDesc("商品视频");
        vodInfo.setCateId((int) System.currentTimeMillis());
        vodInfo.setTags(null);
        if (locVideoList.get(0).getRealPath() != null) {
            uploader.addFile(locVideoList.get(0).getRealPath(), vodInfo);
        } else {
            uploader.addFile(locVideoList.get(0).getPath(), vodInfo);
        }
    }

    //添加多个文件
    private void addSomeFileToAli(String videoName) {
        VodInfo vodInfo = new VodInfo();
        vodInfo.setTitle(videoName);
        vodInfo.setDesc("自定义视频");
        vodInfo.setCateId((int) System.currentTimeMillis());
        vodInfo.setTags(null);
        if (mPVideoSelectList.get(mVideoAdapterPosition).get(0).getRealPath() != null) {
            uploader.addFile(mPVideoSelectList.get(mVideoAdapterPosition).get(0).getRealPath(), vodInfo);
        } else {
            uploader.addFile(mPVideoSelectList.get(mVideoAdapterPosition).get(0).getPath(), vodInfo);
        }
    }

    public void isSku(List<GetSkuEntity1> data) {
        getSkuEntities = data;
        if (data != null && data.size() != 0) {
            binding.llSpec.setVisibility(View.VISIBLE);
            binding.itemTvPrice.setVisibility(View.GONE);
            islooks = false;
        } else {
            binding.llSpec.setVisibility(View.GONE);
            binding.itemTvPrice.setVisibility(View.VISIBLE);
            islooks = true;
        }
    }

    public void showSuccess() {
        MToast.showToast(GoodsPublishActivity.this, "发布成功!");
        binding.nextView.setClickable(false);
        EventBus.getDefault().postSticky(GoodsEvent.make().setMessageTag(EVENT_GOODS_PUBLISH));
        if (id == null) {
            GoodsListActivity3.start(this);
        }
        finish();
    }

    public void isError(String msg) {
        if (!TextUtils.isEmpty(msg) && msg.startsWith("[") && msg.endsWith("]")) {
            //平台已关闭部分服务属性自定义功能，请核对后发布！[1, 583, 589]
            String msgTemp = msg.replace("[", "").replace("]", "");
            if (!TextUtils.isEmpty(msgTemp)) {
                String[] stringArray = msgTemp.split(",");
//            List<String> stringB = new Gson().fromJson(msg, ArrayList.class);
                for (int a = 0; a < stringArray.length; a++) {
                    for (int p = 0; p < listService.size(); p++) {
                        for (int m = 0; m < listService.get(p).getValue().size(); m++) {
                            if (stringArray[a].trim().equals(String.valueOf(listService.get(p).getValue().get(m).getServerId()))) {
                                for (Iterator<GoodsServicesEntity.TypeValue.ItemValue> iterator = listService.get(p).getValue().get(m).getValue().iterator(); iterator.hasNext(); ) {
                                    GoodsServicesEntity.TypeValue.ItemValue itemValue = iterator.next();
                                    if (1 == itemValue.getCustomed()) {
                                        iterator.remove();
                                    }
                                }
                                listService.get(p).getValue().get(m).setIsChange("1");
                                listService.get(p).getValue().get(m).setServerCustomed(1);
                            }
                        }
                    }
                }
                List<GoodsPublishInfoEntity> serverInfoDTOS = new ArrayList<>();
                for (int m = 0; m < listService.size(); m++) {
                    for (int n = 0; n < listService.get(m).getValue().size(); n++) {
                        for (int l = 0; l < listService.get(m).getValue().get(n).getValue().size(); l++) {
                            GoodsPublishInfoEntity itemInfo = new GoodsPublishInfoEntity();
                            itemInfo.setServiceType(listService.get(m).getServiceType());
                            itemInfo.setServerName(listService.get(m).getValue().get(n).getValue().get(l).getServerName());
                            itemInfo.setAttributeId(listService.get(m).getValue().get(n).getValue().get(l).getAttributeId());
                            itemInfo.setAttributeName(listService.get(m).getValue().get(n).getValue().get(l).getAttributeName());
                            itemInfo.setChecked(listService.get(m).getValue().get(n).getValue().get(l).getChecked());
                            itemInfo.setCustomed(listService.get(m).getValue().get(n).getValue().get(l).getCustomed());
                            itemInfo.setId(listService.get(m).getValue().get(n).getValue().get(l).getId());
                            itemInfo.setSort(listService.get(m).getValue().get(n).getValue().get(l).getSort());
                            itemInfo.setServerId(listService.get(m).getValue().get(n).getServerId());
                            itemInfo.setDeleted(listService.get(m).getValue().get(n).getValue().get(l).getDeleted());
                            serverInfoDTOS.add(itemInfo);
                        }
                    }
                }
                viewModel.sTPublishEntity.get().setServerInfoDTOS(serverInfoDTOS);
                viewModel.goodsPublishEntity.get().setServerInfoDTOS(serverInfoDTOS);

                new RoundDialog.Builder(GoodsPublishActivity.this)
                        .title("温馨提示")
                        .content("平台已关闭部分服务属性自定义功能，请核对后发布！\n （已为您标记发生变更的服务属性）")
                        .confirm("知道了")
                        .singleBtn(true)
                        .contentGravity(Gravity.CENTER)
                        .confirmCallback(new RoundDialog.SingleCallback() {
                            @Override
                            public void onClick(View v) {
                                binding.tvChip.setLabelNameColor(ColorUtils.getColor(R.color.color_EF4033));
                            }
                        })
                        .cancelable(false)
                        .show();
            }
        } else {

        }
        uploadImgList.clear();
        currentImgNum = 0;
        binding.nextView.setClickable(true);
    }

    public void setStrength(List<STArrEntity> strength) {
        this.strength = strength;
        for (int i = 0; i < strength.size(); i++) {
            if ("strength".equals(strength.get(i).getName())) {
                strengthGradeAdapter.setDatas(strength.get(i).getChildList());
            } else if ("admixture".equals(strength.get(i).getName())) {
                admixtureAdapter.setDatas(strength.get(i).getChildList());
            }
        }
    }

    public void setStrength2(List<STArrEntity> strength) {
        this.strength = strength;
        for (int i = 0; i < strength.size(); i++) {
            if ("strength".equals(strength.get(i).getName())) {
//                strengthGradeAdapter.setDatas(strength.get(i).getChildList());
                for (int n = 0; n < viewModel.sTPublishEntity.get().getStrengthList().getChildList().size(); n++) {
                    for (int j = 0; j < strength.get(i).getChildList().size(); j++) {
                        if (viewModel.sTPublishEntity.get().getStrengthList().getChildList().get(n).getName().equals(strength.get(i).getChildList().get(j).getName())) {
                            strength.get(i).getChildList().get(j).setPrice(viewModel.sTPublishEntity.get().getStrengthList().getChildList().get(n).getPrice());
                        }
                    }
                }
                strengthGradeAdapter.setDatas(strength.get(i).getChildList());
            } else if ("admixture".equals(strength.get(i).getName())) {
//                admixtureAdapter.setDatas(strength.get(i).getChildList());
                for (int n = 0; n < viewModel.sTPublishEntity.get().getAdmixtureList().getChildList().size(); n++) {
                    for (int j = 0; j < strength.get(i).getChildList().size(); j++) {
                        if (viewModel.sTPublishEntity.get().getAdmixtureList().getChildList().get(n).getName().equals(strength.get(i).getChildList().get(j).getName()) && viewModel.sTPublishEntity.get().getAdmixtureList().getChildList().get(n).getSpec().equals(strength.get(i).getChildList().get(j).getSpec())) {
                            strength.get(i).getChildList().get(j).setPrice(viewModel.sTPublishEntity.get().getAdmixtureList().getChildList().get(n).getPrice());
                        }
                    }
                }
                admixtureAdapter.setDatas(strength.get(i).getChildList());
            }
        }
/*

        if (viewModel.sTPublishEntity.get().getAdmixtureList() != null) {
            if (viewModel.sTPublishEntity.get().getAdmixtureList().getChildList() != null && viewModel.sTPublishEntity.get().getAdmixtureList().getChildList().size() != 0) {
                admixtureAdapter.setDatas(viewModel.sTPublishEntity.get().getAdmixtureList().getChildList());
            }
        }
        if (viewModel.sTPublishEntity.get().getStrengthList() != null) {
            if (viewModel.sTPublishEntity.get().getStrengthList().getChildList() != null && viewModel.sTPublishEntity.get().getStrengthList().getChildList().size() != 0) {
                strengthGradeAdapter.setDatas(viewModel.sTPublishEntity.get().getStrengthList().getChildList());
            }
        }*/
    }

    public void setAlbum(List<AlbumEntity> album) {
        this.albumEntityList = album;
        selectAlbumPopWindow.setData(albumEntityList);
        cName3IsChange = false;
        showAlbumPop();
    }

    private void showAlbumPop() {
        if (!selectAlbumPopWindow.isShowing()) {
            selectAlbumPopWindow.showDownPopwindow(binding.grayLayout, true);
        }
    }

    private void showSaveDialog() {
        View view = View.inflate(this, R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(this, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失

        TextView tv_confirm = (TextView) view.findViewById(R.id.tv_logout_confirm);
        TextView tv_message = (TextView) view.findViewById(R.id.tv_message);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = (TextView) view.findViewById(R.id.tv_logout_confirm);
        tv_title.setVisibility(View.VISIBLE);
        TextView tv_logout_cancel = (TextView) view.findViewById(R.id.tv_logout_cancel);
        tv_title.setText("温馨提示");
        tv_confirm.setText("保存");
        tv_logout_cancel.setText("不保存");
        tv_message.setText("是否保存草稿?");
        //确定
        tv_logout_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (isST) {
                    stCheck();//商砼验证
                } else {
                    goodsCheck();//商品验证
                }
                roundCornerDialog.dismiss();
            }
        });

        //取消
        tv_logout_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                roundCornerDialog.dismiss();
                finish();
            }
        });
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back_view:
                if (IS_START_PUBLISH) {
                    showSaveDialog();
                } else {
                    finish();
                }
                break;
            case R.id.next_view:
                IS_START_PUBLISH = false;//商品直接发布不保存草稿
                if (isST) {
                    stCheck();//商砼验证
                } else {
                    goodsCheck();//商品验证
                }
                break;
            case R.id.tv_title_click:
                if ("".equals(binding.etName.getText().toString().trim())) {
                    MToast.showToast(GoodsPublishActivity.this, "请填写完整名称、分类后预览");
                    return;
                } else if ("".equals(binding.itemTvArr.getContent())) {
                    MToast.showToast(GoodsPublishActivity.this, "请填写完整名称、分类后预览");
                    return;
                }
                if (TextUtils.isEmpty(viewModel.goodsPublishEntity.get().getBrandName())) {
                    binding.etTitleLook.setText(viewModel.goodsPublishEntity.get().getName() + "/" + viewModel.goodsPublishEntity.get().getCid3Name());
                } else {
                    binding.etTitleLook.setText(viewModel.goodsPublishEntity.get().getName() + "/" +
                            viewModel.goodsPublishEntity.get().getBrandName() + "/" + viewModel.goodsPublishEntity.get().getCid3Name());
                }
                break;
            case R.id.add_video:
                PictureSelector.create(GoodsPublishActivity.this)
                        .openGallery(PictureMimeType.ofVideo())
                        .loadImageEngine(GlideEngine.createGlideEngine())
                        .theme(R.style.picture_default_style)
                        .maxSelectNum(1)
                        .selectionMedia(locVideoList)
                        .forResult(PictureConfig.TYPE_VIDEO);
                break;
            case R.id.delete_tv:
                /*locVideoList.clear();
                viewModel.goodsPublishEntity.get().setVideoId("");*/
                //停止播放
                binding.videoView.release();
                binding.rlVideo.setVisibility(View.GONE);
                break;

        }

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            if (requestCode == PictureConfig.CHOOSE_REQUEST) {// 图片结果回调
                // 图片、视频、音频选择结果回调
                selectList = PictureSelector.obtainMultipleResult(data);
                fileList.clear();
                urls.clear();
                //裁剪地址
                for (LocalMedia localMedia : selectList) {
                    File file;
                    file = new File(localMedia.getCompressPath());
                    fileList.add(file);
                    urls.add(localMedia.getCompressPath());
                }
                adapter.setDatas(selectList, urls);
                adapter.setFileList(fileList);
                selectAlbumPopWindow.dismiss();
            } else if (requestCode == PictureConfig.TYPE_VIDEO) {
                locVideoList = PictureSelector.obtainMultipleResult(data);
                videoSelectPopWindow.setData(locVideoList, indexVideo);
//                addFileToAli();
//                viewModel.getVideoParams();
//                showVideoDetailView(locVideoList.get(0).getPath());
            } else if (requestCode == IMAGE_ADAPTER_LIST) {
                //ImageAdapter列表
                mPImgSelectList.put(mImageAdapterPosition, PictureSelector.obtainMultipleResult(data));
                List<File> fileList = new ArrayList<>();
                List<String> urls = new ArrayList<>();
                for (LocalMedia localMedia : PictureSelector.obtainMultipleResult(data)) {
                    File file;
                    file = new File(localMedia.getCompressPath());
                    urls.add(localMedia.getCompressPath());
                    fileList.add(file);
                }
                mPImgAdapter.get(mImageAdapterPosition).setDatas(PictureSelector.obtainMultipleResult(data), urls);
                mPImgAdapter.get(mImageAdapterPosition).setFileList(fileList);
                upAdapterImg(mPImgAdapter.get(mImageAdapterPosition).getFileList(), mImageAdapterPosition);
            } else if (requestCode == VIDEO_ADAPTER_LIST) {
                //VideoAdapter列表
                mPVideoSelectList.put(mVideoAdapterPosition, PictureSelector.obtainMultipleResult(data));
                videoListSelectPopWindow.setData(PictureSelector.obtainMultipleResult(data), mPVideoIndex.get(mVideoAdapterPosition));
                               /* List<File> fileList = new ArrayList<>();
                List<VideoEntity> urls = new ArrayList<>();
                for (LocalMedia localMedia : PictureSelector.obtainMultipleResult(data)) {
                    VideoEntity videoEntity = new VideoEntity();
                    File file = new File(localMedia.getRealPath());
                    fileList.add(file);
                    videoEntity.setUrl(localMedia.getRealPath());
                    videoEntity.setTitle(localMedia.getFileName());
                    urls.add(videoEntity);
                }
                mPVideoAdapter.get(mVideoAdapterPosition).setAdapterListDatas(PictureSelector.obtainMultipleResult(data), urls);
                mPVideoAdapter.get(mVideoAdapterPosition).setFileList(fileList);*/

            } else if (requestCode == 90001) {
                listService = (List<GoodsServicesEntity>) data.getSerializableExtra("listService");
                Log.e("111111", "1111111111");
                if (isHasChecked(listService)) {
                    binding.tvChip.setContent("已填写");
                } else {
                    binding.tvChip.setContent("");
                }
                binding.tvChip.setLabelNameColor(ColorUtils.getColor(R.color.color_tab_one));
                List<GoodsPublishInfoEntity> serverInfoDTOS = new ArrayList<>();
                for (int m = 0; m < listService.size(); m++) {
                    for (int n = 0; n < listService.get(m).getValue().size(); n++) {
                        for (int l = 0; l < listService.get(m).getValue().get(n).getValue().size(); l++) {
                            GoodsPublishInfoEntity itemInfo = new GoodsPublishInfoEntity();
                            itemInfo.setServiceType(listService.get(m).getServiceType());
                            itemInfo.setServerName(listService.get(m).getValue().get(n).getValue().get(l).getServerName());
                            itemInfo.setAttributeId(listService.get(m).getValue().get(n).getValue().get(l).getAttributeId());
                            itemInfo.setAttributeName(listService.get(m).getValue().get(n).getValue().get(l).getAttributeName());
                            itemInfo.setChecked(listService.get(m).getValue().get(n).getValue().get(l).getChecked());
                            itemInfo.setCustomed(listService.get(m).getValue().get(n).getValue().get(l).getCustomed());
                            itemInfo.setId(listService.get(m).getValue().get(n).getValue().get(l).getId());
                            itemInfo.setSort(listService.get(m).getValue().get(n).getValue().get(l).getSort());
                            itemInfo.setServerId(listService.get(m).getValue().get(n).getServerId());
                            itemInfo.setDeleted(listService.get(m).getValue().get(n).getValue().get(l).getDeleted());
                            serverInfoDTOS.add(itemInfo);
                        }
                    }
                }
                viewModel.sTPublishEntity.get().setServerInfoDTOS(serverInfoDTOS);
                viewModel.goodsPublishEntity.get().setServerInfoDTOS(serverInfoDTOS);
            }
        }
    }


    private boolean isHasChecked(List<GoodsServicesEntity> listService) {
        List<Integer> tempData = new ArrayList<>();
        for (int x = 0; x < listService.size(); x++) {
            for (int y = 0; y < listService.get(x).getValue().size(); y++) {
                for (int z = 0; z < listService.get(x).getValue().get(y).getValue().size(); z++) {
                    int checked = listService.get(x).getValue().get(y).getValue().get(z).getChecked();
                    tempData.add(checked);
                }
            }
        }
        if (tempData.contains(1)) {
            return true;
        }
        return false;
    }


    @Override
    public void OnWholeItemClick(View view) {
        switch (view.getId()) {
            case R.id.item_tv_arr:
                if (id == null)
                    if (goodsTypeEntityList != null) {
                        showGoodsTypePop();
                    } else {
                        viewModel.getGoodsCategory();
                    }
                break;
            case R.id.item_tv_unit:
                if (unitEntityList != null) {
                    showUnitPop(false);
                } else {
                    viewModel.getUnitList("");
                }
                break;
            case R.id.item_tv_futures:
                if (!futuresPopWindow.isShowing()) {
                    if (TextUtils.isEmpty(dataText)) {
                        futuresPopWindow.showDownPopwindow(binding.grayLayout, true);
                    } else {
                        futuresPopWindow.setPopData(dataText, isSelectLeft, isSelectDay, binding.grayLayout);
                    }
                }
                break;
            case R.id.item_tv_storage:
                if (storageManEntityList != null) {
                    storagePopWindow.showDownPopwindow(binding.grayLayout, true);
                } else {
                    viewModel.getStorageList(search, false);
                }
                break;
            case R.id.item_tv_brand:
                if (viewModel.goodsPublishEntity.get().getCid3() == null) {
                    MToast.showToast(GoodsPublishActivity.this, "请先选择商品分类");
                    return;
                }

                if (typeSelect) {
                    brandEntityList = null;
                    typeSelect = false;
                }

                if (brandEntityList != null) {
                    brandPopWindow.showDownPopwindow(binding.grayLayout, true);
                } else {
                    viewModel.getBrandList(viewModel.goodsPublishEntity.get().getCid3(), brandSearch);
                }
                break;
            case R.id.item_tv_area:
                if (id == null)
                    if (parentAreaEntities == null) {
                        viewModel.getAreaModel();
                    } else {
                        showCityPop();
                    }
                break;
            case R.id.item_tv_spec:
                if (!"".equals(binding.itemTvSpec.getContent())) {
                    GoodsSkuEvent goodsEvent = new GoodsSkuEvent();
                    goodsEvent.setMessageTag(EVENT_SELECT_ARR);
                    goodsEvent.setMessageData(viewModel.goodsPublishEntity.get().getSkuOldList());
                    goodsEvent.setObject(combination);
                    EventBus.getDefault().postSticky(goodsEvent);
                }
                GoodsSpecActivity.start(GoodsPublishActivity.this, viewModel.goodsPublishEntity.get().getCid3(), id);
                break;
            case R.id.tv_chip:
                Intent intent = new Intent(GoodsPublishActivity.this, ChipActivity.class);
                intent.putExtra("listService", (Serializable) listService);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                GoodsPublishActivity.this.startActivityForResult(intent, 90001);
                break;
            default:
                break;
        }

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onReturnEvent(GoodsEvent event) {
        if (event.getMessageTag() == EVENT_STORAGE_ADD) {
            viewModel.getStorageList("", false);
        } else if (event.getMessageTag() == EVENT_BRAND_ADD) {
            viewModel.getBrandList(viewModel.goodsPublishEntity.get().getCid3(), "");
        } else if (event.getMessageTag() == EVENT_SPEC_PRICE) {
            binding.itemTvSpec.setContent("已填写");
            combination = (List<GoodsPublishSkuListEntity>) event.getObject();
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent2(MaterialEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_GOODS_NET_IMG_SELECT) {
            //选中的图片URL
            List<String> netUrl = (List<String>) event.getObject();
            //未选中的图片URL
            List<String> unSelectUrl = (List<String>) event.getMessageData();
            adapter.updateNetImgList(netUrl, unSelectUrl);
            selectAlbumPopWindow.dismiss();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
        try {
            binding.videoView.releaseAllVideos();
        } catch (Exception e) {
        }
    }

    protected void hideInput() {
        InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        View v = getWindow().peekDecorView();
        if (null != v) {
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }
    }

    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        sensorManager.unregisterListener(sensorEventListener);
        JCVideoPlayer.releaseAllVideos();
    }

    @Override
    protected void onResume() {
        super.onResume();
        Sensor accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        sensorManager.registerListener(sensorEventListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);
    }

    public void setHtml(String htmls) {
        if (htmls == null) {
            binding.yesData.setVisibility(View.GONE);
            binding.yesDataSubtitle.setText("(暂无数据，手机不支持编辑，请使用电脑后台编辑)");
            return;
        }
        binding.yesData.setVisibility(View.VISIBLE);
        binding.yesDataSubtitle.setText("(手机不支持编辑，请使用电脑后台编辑)");
        Document doc = Jsoup.parseBodyFragment(htmls);
        Elements elements = doc.select("img");
        for (Element each : elements) {
            each.attr("style", "width:100%");
        }

        String html = doc.html();
        Document htmlResult = Jsoup.parseBodyFragment(html);
        elements = htmlResult.select("body");
        for (Element each : elements) {
            each.attr("style", "font-size:34px");
        }
        elements = htmlResult.getElementsByTag("p");
        for (Element element : elements) {
            element.attr("style", "color:#666666");
        }
        MLog.d("", htmlResult.html());

        binding.webView.loadData(htmlResult.html(), "text/html; charset=UTF-8", null);
        binding.webView.getSettings().setJavaScriptEnabled(true);
        binding.webView.getSettings().setSupportZoom(false);
        binding.webView.getSettings().setBuiltInZoomControls(false);
        binding.webView.getSettings().setUseWideViewPort(true);
        binding.webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        binding.webView.getSettings().setLoadWithOverviewMode(true);
        binding.webView.setBackgroundColor(getResources().getColor(R.color.color_F5F5F5)); // 设置背景色
        binding.webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                binding.webView.loadUrl("javascript:document.body.style.padding=\"3.2%\"; void 0");
            }
        });
    }

    //商品验证
    private void goodsCheck() {
        setOtherData();
        viewModel.goodsPublishEntity.get().setAttrList(attrChildEntityList);
        if (viewModel.goodsPublishEntity.get().getAttrList() != null) {
            for (int i = 0; i < viewModel.goodsPublishEntity.get().getAttrList().size(); i++) {
                if (viewModel.goodsPublishEntity.get().getAttrList().get(i).getAttrValue() == null && viewModel.goodsPublishEntity.get().getAttrList().get(i).getIsfill() != null && 1 == viewModel.goodsPublishEntity.get().getAttrList().get(i).getIsfill()) {
                    arrName = viewModel.goodsPublishEntity.get().getAttrList().get(i).getAttrKey();
                    isSelect = false;
                    break;
                }
                isSelect = true;
            }
        }
        if (TextUtils.isEmpty(binding.itemTvArr.getContent())) {
            MToast.showToast(GoodsPublishActivity.this, "请选择商品分类");
            return;
        } else if (TextUtils.isEmpty(binding.etName.getText().toString().trim())) {
            MToast.showToast(GoodsPublishActivity.this, "请输入商品名称");
            return;
        } else if (binding.etName.getText().toString().trim().length() > 32) {
            MToast.showToast(GoodsPublishActivity.this, "商品名称字数超出限制");
            return;
        } else if (TextUtils.isEmpty(binding.itemTvStorage.getContent())) {
            MToast.showToast(GoodsPublishActivity.this, "请选择仓储");
            return;
        } else if (TextUtils.isEmpty(binding.itemTvTax.getContent())) {
            MToast.showToast(GoodsPublishActivity.this, "请输入税率");
            return;
        } else if (!isSelect && (arrEntityList != null && arrEntityList.size() != 0)) {
            MToast.showToast(GoodsPublishActivity.this, "请选择" + arrName);
            return;
        } else if (TextUtils.isEmpty(binding.itemTvUnit.getContent())) {
            MToast.showToast(GoodsPublishActivity.this, "请选择单位");
            return;
        } else if (getSkuEntities != null && getSkuEntities.size() != 0 && binding.itemTvSpec.getContent().equals("")) {
            MToast.showToast(GoodsPublishActivity.this, "请配置规格属性");
            return;
        } else if (adapter.getUrls().size() == 0) {
            MToast.showToast(GoodsPublishActivity.this, "请选择图片");
            return;
        } else if (TextUtils.isEmpty(binding.itemBuyLow.getContent())) {
            MToast.showToast(GoodsPublishActivity.this, "请输入最低采购量");
            return;
        }
        viewModel.goodsPublishEntity.get().setLowestBuy(binding.itemBuyLow.getContent());
        if (binding.itemTvSpec.getContent().equals("")) {
            if (arrEntityList != null && arrEntityList.size() != 0 && TextUtils.isEmpty(binding.itemTvPrice.getContent())) {
                MToast.showToast(GoodsPublishActivity.this, "请输入单价");
                return;
            }
        }
        if (islooks == true) {
            if (TextUtils.isEmpty(binding.itemTvPrice.getContent())) {
                MToast.showToast(GoodsPublishActivity.this, "请输入单价");
                return;
            }
            if (Double.valueOf(binding.itemTvPrice.getContent()) == 0) {
                MToast.showToast(GoodsPublishActivity.this, "请输入正确的单价");
                return;
            }
            if (Objects.requireNonNull(viewModel.goodsPublishEntity.get()).getSkuList() != null && viewModel.goodsPublishEntity.get().getSkuList().size() == 1 && !TextUtils.isEmpty(viewModel.goodsPublishEntity.get().getSkuList().get(0).getMoney()) && !TextUtils.isEmpty(viewModel.goodsPublishEntity.get().getSkuList().get(0).getVipMaxPrice())) {
                BigDecimal money = new BigDecimal(binding.itemTvPrice.getContent());
                BigDecimal vipMaxPrice = new BigDecimal(viewModel.goodsPublishEntity.get().getSkuList().get(0).getVipMaxPrice());
                if (money.compareTo(vipMaxPrice) == -1) {
                    //平销价小于会员价
                    MToast.showToast(GoodsPublishActivity.this, "平销价不能低于会员价");
                    return;
                }
            }
        }
        if (TextUtils.isEmpty(viewModel.goodsPublishEntity.get().getBrandName())) {
            binding.etTitleLook.setText(viewModel.goodsPublishEntity.get().getName() + "/" + viewModel.goodsPublishEntity.get().getCid3Name());
        } else {
            binding.etTitleLook.setText(viewModel.goodsPublishEntity.get().getName() + "/" +
                    viewModel.goodsPublishEntity.get().getBrandName() + "/" + viewModel.goodsPublishEntity.get().getCid3Name());
        }
        if (getSkuEntities != null && combination != null && getSkuEntities.size() != 0) {
            for (int i = 0; i < combination.size(); i++) {
                combination.get(i).setCategory(cId3);
                combination.get(i).setUnit(binding.itemTvUnit.getContent());
            }
            viewModel.goodsPublishEntity.get().setSkuList(combination);
        } else {
            List<GoodsPublishSkuListEntity> skuList = new ArrayList<>();
            GoodsPublishSkuListEntity goodsPublishSkuListEntity = new GoodsPublishSkuListEntity();
            goodsPublishSkuListEntity.setCategory(cId3);
            goodsPublishSkuListEntity.setMoney(binding.itemTvPrice.getContent());
            goodsPublishSkuListEntity.setType(0);
            if (viewModel.goodsPublishEntity.get().getSkuOldList() != null && viewModel.goodsPublishEntity.get().getSkuOldList().size() != 0)
                goodsPublishSkuListEntity.setId(viewModel.goodsPublishEntity.get().getSkuOldList().get(0).getId());
            skuList.add(goodsPublishSkuListEntity);
            viewModel.goodsPublishEntity.get().setSkuList(skuList);
        }
        viewModel.goodsPublishEntity.get().setCompanyId(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.REAL_ID, ""));
        if (adapter.getFileList().size() != 0) {
            uploadImgList.clear();
            imgTotal = adapter.getFileList().size();
            viewModel.uploadMutiFileModel(adapter.getFileList().get(currentImgNum), 0, currentImgNum + 1);
        } else {
            uploadImgSuccess(adapter.getUrls(), 1);
        }

    }

    //商砼验证
    private void stCheck() {
        setOtherData();
        if (TextUtils.isEmpty(binding.etName.getText().toString().trim())) {
            MToast.showToast(GoodsPublishActivity.this, "请输入商品名称");
            return;
        } else if (binding.etName.getText().toString().trim().length() > 32) {
            MToast.showToast(GoodsPublishActivity.this, "商品名称字数超出限制");
            return;
        } else if (TextUtils.isEmpty(binding.itemTvStorage.getContent())) {
            MToast.showToast(GoodsPublishActivity.this, "请选择仓储");
            return;
        } else if (TextUtils.isEmpty(binding.itemTvTax.getContent())) {
            MToast.showToast(GoodsPublishActivity.this, "请输入税率");
            return;
        } else if (!strengthCheck()) {
            MToast.showToast(GoodsPublishActivity.this, "请填写强度等级");
            return;
        } else if (!strengthCheckZero()) {
            MToast.showToast(GoodsPublishActivity.this, "强度等级价格不能为0,请仔细检查");
            return;
        } else if (adapter.getUrls().size() == 0) {
            MToast.showToast(GoodsPublishActivity.this, "请选择图片");
            return;
        }
        //名称
        viewModel.sTPublishEntity.get().setTitle(binding.etName.getText().toString());
        //描述
        viewModel.sTPublishEntity.get().setItemDesc(binding.etMark.getText().toString());
        //税率
        viewModel.sTPublishEntity.get().setTax(binding.itemTvTax.getContent());
        //单位
        viewModel.sTPublishEntity.get().setUnit(binding.itemTvStunit.getContent());
        //泵送
        viewModel.sTPublishEntity.get().setPumpPrice(binding.itemTvBsprice.getContent());
        //配置
        viewModel.sTPublishEntity.get().setGradation1Price(binding.itemTvLeavePrice.getContent());
        strengthCheckData();
        if (wjjCheck()) {
            wjjCheckData();
        }
        if (strength != null) {
            for (int i = 0; i < strength.size(); i++) {
                if ("strength".equals(strength.get(i).getName())) {
                    STArrEntity stArrEntity1 = new STArrEntity();
                    stArrEntity1 = strength.get(i);
                    stArrEntity1.setChildList(strengthEntityList);
                    viewModel.sTPublishEntity.get().setStrengthList(stArrEntity1);
                    viewModel.sTPublishEntity.get().getStrengthList().setChildList(strengthEntityList);
                } else if ("admixture".equals(strength.get(i).getName())) {
                    STArrEntity stArrEntity2 = new STArrEntity();
                    stArrEntity2 = strength.get(i);
                    stArrEntity2.setChildList(wjjList);
                    viewModel.sTPublishEntity.get().setAdmixtureList(stArrEntity2);
                }
            }
        }
        viewModel.sTPublishEntity.get().setCompanyId(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.REAL_ID, ""));
        if (adapter.getFileList().size() != 0) {
            uploadImgList.clear();
            imgTotal = adapter.getFileList().size();
            viewModel.uploadMutiFileModel(adapter.getFileList().get(currentImgNum), 0, currentImgNum + 1);
            //viewModel.uploadGoodsImg(adapter.getFileList(), 0, currentImgNum + 1);
        } else {
            uploadImgSuccess(adapter.getUrls(), 1);
        }
    }

    //强度等级验证
    private boolean strengthCheck() {
        for (int i = 0; i < strengthGradeAdapter.getDatas().size(); i++) {
            if (strengthGradeAdapter.getDatas().get(i).getPrice() != null && !"".equals(strengthGradeAdapter.getDatas().get(i).getPrice())) {
                return true;
            }
        }
        return false;
    }

    //强度等级验证
    private boolean strengthCheckZero() {
        for (int i = 0; i < strengthGradeAdapter.getDatas().size(); i++) {
            if (strengthGradeAdapter.getDatas().get(i).getPrice() != null && !"".equals(strengthGradeAdapter.getDatas().get(i).getPrice()) && Double.valueOf(strengthGradeAdapter.getDatas().get(i).getPrice()) == 0) {
                return false;
            }
        }
        return true;
    }

    //外加剂
    private boolean wjjCheck() {
        wjjList = new ArrayList<>();
        for (int i = 0; i < admixtureAdapter.getDatas().size(); i++) {
            if (admixtureAdapter.getDatas().get(i).getPrice() != null && !"".equals(admixtureAdapter.getDatas().get(i).getPrice())) {
                return true;
            }
        }
        return false;
    }

    //强度等级数据转换
    private void strengthCheckData() {
        if (strengthEntityList == null) {
            strengthEntityList = new ArrayList<>();
        }
        strengthEntityList.clear();
        for (int i = 0; i < strengthGradeAdapter.getDatas().size(); i++) {
            if (strengthGradeAdapter.getDatas().get(i).getPrice() != null && !"".equals(strengthGradeAdapter.getDatas().get(i).getPrice())) {
                strengthEntityList.add(strengthGradeAdapter.getDatas().get(i));
            }
        }
    }

    //外加剂数据转换
    private void wjjCheckData() {
        wjjList.clear();
        for (int i = 0; i < admixtureAdapter.getDatas().size(); i++) {
            if (admixtureAdapter.getDatas().get(i).getPrice() != null && !"".equals(admixtureAdapter.getDatas().get(i).getPrice())) {
                wjjList.add(admixtureAdapter.getDatas().get(i));
            }
        }
    }

    private void setGoneAndDisplay() {
        if (!isST) {
            binding.itemTvBrand.setVisibility(View.VISIBLE);
            binding.itemTvUnit.setVisibility(View.VISIBLE);
            if (viewModel.goodsPublishEntity.get().getSkuList() != null && viewModel.goodsPublishEntity.get().getSkuList().size() != 0) {
                binding.itemTvPrice.setVisibility(View.VISIBLE);
                islooks = true;
            } else {
                binding.itemTvPrice.setVisibility(View.GONE);
                islooks = false;
            }
            binding.llPreview.setVisibility(View.VISIBLE);
            binding.itemTvBsprice.setVisibility(View.GONE);
            binding.itemTvLeavePrice.setVisibility(View.GONE);
            binding.itemTvStunit.setVisibility(View.GONE);
            binding.llSt.setVisibility(View.GONE);

        } else {
            binding.itemTvBrand.setVisibility(View.GONE);
            binding.itemTvUnit.setVisibility(View.GONE);
            binding.itemTvPrice.setVisibility(View.GONE);
            islooks = false;
            binding.recyclerArr.setVisibility(View.GONE);
            binding.llPreview.setVisibility(View.GONE);
            binding.itemTvBsprice.setVisibility(View.VISIBLE);
            binding.itemTvLeavePrice.setVisibility(View.VISIBLE);
            binding.itemTvStunit.setVisibility(View.VISIBLE);
            binding.llSt.setVisibility(View.VISIBLE);

        }
    }


    public void addMoveLayout
            (List<AddLayoutEntity<List<AddLayoutEntity>>> addLayoutEntityList) {
        this.addLayoutEntityList = addLayoutEntityList;
        List<ItemInputTextView> itemInputTextViews = new ArrayList<>();
        List<LinearLayout> linearLayouts = new ArrayList<>();
        binding.llOther.removeAllViewsInLayout();
        binding.llOther.addView(binding.tvOther);
        if (this.addLayoutEntityList != null && this.addLayoutEntityList.size() != 0) {
            binding.tvOther.setVisibility(View.VISIBLE);
            for (int i = 0; i < addLayoutEntityList.size(); i++) {
                ItemInputTextView pitemInputTextView = new ItemInputTextView(GoodsPublishActivity.this);
                //子布局
                LinearLayout pLinearLayout = new LinearLayout(GoodsPublishActivity.this);
                pLinearLayout.setVisibility(View.GONE);
                pLinearLayout.setBackgroundColor(getResources().getColor(R.color.color_FAFAFA));
                pLinearLayout.setOrientation(LinearLayout.VERTICAL);
                binding.llOther.addView(pitemInputTextView);
                binding.llOther.addView(pLinearLayout);
                //获取TextView对应的LayoutParams
                LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) pitemInputTextView.getLayoutParams();
                pitemInputTextView.setBackgroundColor(getResources().getColor(R.color.white));
                layoutParams.height = DensityUtils.dip2px(this, 50);
                LinearLayout.LayoutParams pLinearLayoutLayoutParams = (LinearLayout.LayoutParams) pLinearLayout.getLayoutParams();
                pLinearLayoutLayoutParams.leftMargin = DensityUtils.dip2px(this, 10);
                pLinearLayoutLayoutParams.rightMargin = DensityUtils.dip2px(this, 10);
                pitemInputTextView.setLabelName(addLayoutEntityList.get(i).getName());
                pitemInputTextView.setEtEnabled(false);
                pitemInputTextView.setDefRightImg();
                pitemInputTextView.setDefRightImgMargin(10);
                itemInputTextViews.add(pitemInputTextView);
                linearLayouts.add(pLinearLayout);
                int finalI1 = i;
                itemInputTextViews.get(i).setOnWholeItemClickListener(view -> {
                    if (linearLayouts.get(finalI1).getVisibility() == View.GONE) {
                        //显示布局
                        linearLayouts.get(finalI1).setVisibility(View.VISIBLE);
                        //隐藏下划线
                        itemInputTextViews.get(finalI1).setDeliverLineVG(false);
                        //滑到最底部
                        post(() -> binding.nS.smoothScrollTo(0, 9999));
                        itemInputTextViews.get(finalI1).setRightImg(true);
                    } else {
                        //隐藏布局
                        linearLayouts.get(finalI1).setVisibility(View.GONE);
                        //显示下划线
                        itemInputTextViews.get(finalI1).setDeliverLineVG(true);
                        itemInputTextViews.get(finalI1).setRightImg(false);
                    }
                });
                //最后一个隐藏下划线
                if (i == addLayoutEntityList.size() - 1)
                    pitemInputTextView.setDeliverLineVG(false);
                for (int j = 0; j < addLayoutEntityList.get(i).getSubColumns().size(); j++) {
                    int childPosition = j;
                    if ("input".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getType())) {
                        //画输入框
                        ItemInputTextView itemInputTextView = new ItemInputTextView(GoodsPublishActivity.this);
                        pLinearLayout.addView(itemInputTextView);
                        //获取TextView对应的LayoutParams
                        LinearLayout.LayoutParams itemInputTextViewLayoutParams = (LinearLayout.LayoutParams) itemInputTextView.getLayoutParams();
                        //设置输入框背景颜色
                        itemInputTextView.setBackgroundColor(getResources().getColor(R.color.color_FAFAFA));
                        //设置输入框高度
                        itemInputTextViewLayoutParams.height = DensityUtils.dip2px(this, 50);
                        //设置输入框名称
                        itemInputTextView.setLabelName(addLayoutEntityList.get(i).getSubColumns().get(j).getName());
                        //设置输入框hint
                        itemInputTextView.setHint("请输入" + addLayoutEntityList.get(i).getSubColumns().get(j).getName());
                        //设置输入框标题边距
                        itemInputTextView.setLabelMargin(10);
                        //字数限制
                        itemInputTextView.setEditLength(50);
                        if (addLayoutEntityList.get(i).getSubColumns().size() - 1 == j)
                            itemInputTextView.setDeliverLineVG(false);
                        //设置输入框底部线边距
                        itemInputTextView.setLinMargin(5, 0);
                        //设置输入框可输入
                        itemInputTextView.setEnable(true);
                        //设置输入框可输入
                        itemInputTextView.setArrowVisible(false);
                        //数据回显
                        //判断文本框内容是否为空
                        if (!TextUtils.isEmpty(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal())) {
                            itemInputTextView.setContent(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal());
                        }
                        mPItv.put(addLayoutEntityList.get(i).getSubColumns().get(j).getId(), itemInputTextView);
                    } else if ("textarea".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getType())) {
                        //创建文本框
                        TextAreaEditView textAreaEditView = new TextAreaEditView(GoodsPublishActivity.this);
                        //设置文本框的标题名称
                        textAreaEditView.setTitleStr(addLayoutEntityList.get(i).getSubColumns().get(j).getName());
                        //设置Hint提示语
                        textAreaEditView.setEtHint("请输入" + addLayoutEntityList.get(i).getSubColumns().get(j).getName());
                        //设置最大输入字数
                        textAreaEditView.setMaxText(300);
                        //加入父布局
                        pLinearLayout.addView(textAreaEditView);
                        if (addLayoutEntityList.get(i).getSubColumns().size() - 1 == j)
                            textAreaEditView.setTvLine(View.GONE);
                        if (!TextUtils.isEmpty(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal())) {
                            textAreaEditView.setEditContent(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal());
                        }
                        mPTae.put(addLayoutEntityList.get(i).getSubColumns().get(j).getId(), textAreaEditView);
                    } else if ("pic".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getType())) {
                        //图片控件
                        //外层布局
                        LinearLayout linearLayout = new LinearLayout(GoodsPublishActivity.this);
                        //加入父布局
                        pLinearLayout.addView(linearLayout);
                        //设置本层布局的背景颜色
                        linearLayout.setBackgroundColor(getResources().getColor(R.color.color_FAFAFA));
                        //设置垂直布局
                        linearLayout.setOrientation(LinearLayout.VERTICAL);
                        //创建一个标题控件标题
                        TextView mTitleTextView = new TextView(GoodsPublishActivity.this);
                        //把标题控件加入本层布局
                        linearLayout.addView(mTitleTextView);
                        //得到标题控件的 LayoutParams
                        LinearLayout.LayoutParams textViewLayoutParams = (LinearLayout.LayoutParams) mTitleTextView.getLayoutParams();
                        //设置标题边距
                        textViewLayoutParams.bottomMargin = DensityUtils.dip2px(this, 10);
                        textViewLayoutParams.topMargin = DensityUtils.dip2px(this, 10);
                        textViewLayoutParams.leftMargin = DensityUtils.dip2px(this, 10);
                        //设置标题文字
                        mTitleTextView.setText(addLayoutEntityList.get(i).getSubColumns().get(j).getName());
                        //设置标题颜色
                        mTitleTextView.setTextColor(getResources().getColor(R.color.color_333333));
                        //图片recyclerView
                        RecyclerView recyclerView = new RecyclerView(GoodsPublishActivity.this);
                        //recyclerView加入本层布局
                        linearLayout.addView(recyclerView);
                        if (j != addLayoutEntityList.get(i).getSubColumns().size() - 1) {
                            //分割线
                            TextView line = new TextView(GoodsPublishActivity.this);
                            //加入当前父布局
                            linearLayout.addView(line);
                            line.setBackgroundColor(getResources().getColor(R.color.color_EDEDED));
                            LinearLayout.LayoutParams lineLayoutParams = (LinearLayout.LayoutParams) line.getLayoutParams();
                            lineLayoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;//充满
                            lineLayoutParams.height = 1;
                            lineLayoutParams.rightMargin = DensityUtils.dip2px(this, 5);
                            lineLayoutParams.topMargin = DensityUtils.dip2px(this, 10);
                            lineLayoutParams.leftMargin = DensityUtils.dip2px(this, 5);
                        }
                        //拿到recyclerView的LayoutParams
                        LinearLayout.LayoutParams recyclerViewLayoutParams = (LinearLayout.LayoutParams) recyclerView.getLayoutParams();
                        //设置边距
                        recyclerViewLayoutParams.leftMargin = DensityUtils.dip2px(this, 10);
                        //创建图片选择的adapter
                        ImageAdapter imageAdapter = new ImageAdapter(this, null, null, 5, 1);
                        recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
                        recyclerView.setLayoutManager(new
                                GridLayoutManager(GoodsPublishActivity.this, 4));
                        recyclerView.setAdapter(imageAdapter);

                        mPImgAdapter.put(addLayoutEntityList.get(i).getSubColumns().get(j).getId(), imageAdapter);
                        //数据回显
                        if (!TextUtils.isEmpty(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal()) && !"[]".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal())) {
                            List<String> urls = new Gson().fromJson(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal(), new TypeToken<List<String>>() {
                            }.getType());
                            mPImgAdapter.get(addLayoutEntityList.get(i).getSubColumns().get(j).getId()).setNetImgList(urls);
                        }
                        mPUpUrl.put(addLayoutEntityList.get(i).getSubColumns().get(j).getId(), new ArrayList<>());
                        mPCurrentImgNum.put(addLayoutEntityList.get(i).getSubColumns().get(j).getId(), 0);
                        mPImgAdapter.get(addLayoutEntityList.get(i).getSubColumns().get(j).getId()).OnSelectPop(() -> {
                            mPImgAdapter.get(addLayoutEntityList.get(finalI1).getSubColumns().get(childPosition).getId()).openAlbum(IMAGE_ADAPTER_LIST);
                            mImageAdapterPosition = addLayoutEntityList.get(finalI1).getSubColumns().get(childPosition).getId();
                            mPCurrentImgNum.put(addLayoutEntityList.get(finalI1).getSubColumns().get(childPosition).getId(), 0);
                        });
                    } else if ("video".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getType())) {
                        //图片控件
                        //外层布局
                        LinearLayout linearLayout = new LinearLayout(GoodsPublishActivity.this);
                        //加入父布局
                        pLinearLayout.addView(linearLayout);
                        //设置本层布局的背景颜色
                        linearLayout.setBackgroundColor(getResources().getColor(R.color.color_FAFAFA));
                        //设置垂直布局
                        linearLayout.setOrientation(LinearLayout.VERTICAL);

                        //创建一个标题控件标题
                        TextView mTitleTextView = new TextView(GoodsPublishActivity.this);
                        //把标题控件加入本层布局
                        linearLayout.addView(mTitleTextView);
                        //得到标题控件的 LayoutParams
                        LinearLayout.LayoutParams textViewLayoutParams = (LinearLayout.LayoutParams) mTitleTextView.getLayoutParams();
                        //设置标题边距
                        textViewLayoutParams.bottomMargin = DensityUtils.dip2px(this, 10);
                        textViewLayoutParams.topMargin = DensityUtils.dip2px(this, 10);
                        textViewLayoutParams.leftMargin = DensityUtils.dip2px(this, 10);
                        //设置标题文字
                        mTitleTextView.setText(addLayoutEntityList.get(i).getSubColumns().get(j).getName());
                        //设置标题颜色
                        mTitleTextView.setTextColor(getResources().getColor(R.color.color_333333));
                        //图片recyclerView
                        RecyclerView recyclerView = new RecyclerView(GoodsPublishActivity.this);
                        //recyclerView加入本层布局
                        linearLayout.addView(recyclerView);
                        //添加底部线条
                        if (j != addLayoutEntityList.get(i).getSubColumns().size() - 1) {
                            TextView bottomLine = new TextView(GoodsPublishActivity.this);
                            linearLayout.addView(bottomLine);
                            bottomLine.setBackgroundColor(getResources().getColor(R.color.color_EDEDED));
                            //拿到bottomLine的LayoutParams
                            LinearLayout.LayoutParams bottomLineLayoutParams = (LinearLayout.LayoutParams) bottomLine.getLayoutParams();
                            bottomLineLayoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;//充满
                            bottomLineLayoutParams.height = 1;
                            bottomLineLayoutParams.rightMargin = DensityUtils.dip2px(this, 5);
                            bottomLineLayoutParams.leftMargin = DensityUtils.dip2px(this, 5);
                        }
                        //拿到recyclerView的LayoutParams
                        LinearLayout.LayoutParams recyclerViewLayoutParams = (LinearLayout.LayoutParams) recyclerView.getLayoutParams();
                        //设置边距
                        recyclerViewLayoutParams.leftMargin = DensityUtils.dip2px(this, 10);
                        recyclerViewLayoutParams.bottomMargin = DensityUtils.dip2px(this, 10);
                        //创建视频选择的adapter
                        VideoAdapter videoAdapter = new VideoAdapter(this, null, null, 5, 1);
                        recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
                        recyclerView.setLayoutManager(new
                                GridLayoutManager(GoodsPublishActivity.this, 4));
                        recyclerView.setAdapter(videoAdapter);
                        List<VideoEntity> videoEntities = new ArrayList<>();
                        //数据回显
                        if (!TextUtils.isEmpty(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal()) && !"[]".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal())) {
                            List<VideoChangeEntity> videoChangeEntities = new Gson().fromJson(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal(), new TypeToken<List<VideoChangeEntity>>() {
                            }.getType());
                            if (videoChangeEntities != null) {
                                for (int x = 0; x < videoChangeEntities.size(); x++) {
                                    VideoEntity videoEntity = new VideoEntity();
                                    //视频类型
                                    videoEntity.setType(videoChangeEntities.get(x).getType());
                                    //视频id
                                    videoEntity.setVideoId(videoChangeEntities.get(x).getVideoId());
                                    //视频名称
                                    videoEntity.setTitle(videoChangeEntities.get(x).getVideoName());
                                    //视频地址
                                    videoEntity.setUrl(videoChangeEntities.get(x).getPlayUrl());
                                    //视频时长
                                    videoEntity.setTime(videoChangeEntities.get(x).getTime());
                                    videoEntities.add(videoEntity);
                                }
                            }
                            videoAdapter.setNetImgList(videoEntities);
                        }
                        mPVideoAdapter.put(addLayoutEntityList.get(finalI1).getSubColumns().get(childPosition).getId(), videoAdapter);
                        mPVideoIndex.put(addLayoutEntityList.get(finalI1).getSubColumns().get(childPosition).getId(), 0);
                        mPVideoFile.put(addLayoutEntityList.get(finalI1).getSubColumns().get(childPosition).getId(), new ArrayList<>());
                        mPVideoAdapter.get(addLayoutEntityList.get(finalI1).getSubColumns().get(childPosition).getId()).OnSelectPop(new VideoAdapter.ISelectPop() {
                            @Override
                            public void openPop(int index) {
                                mVideoAdapterPosition = addLayoutEntityList.get(finalI1).getSubColumns().get(childPosition).getId();
                                if (mPVideoAdapter.get(mVideoAdapterPosition).getUrls().size() != 5) {
//                                mPVideoAdapter.get(mVideoAdapterPosition).openVideo(VIDEO_ADAPTER_LIST);
                                    mPVideoIndex.put(mVideoAdapterPosition, index);
                                    //重置弹窗数据
                                    videoListSelectPopWindow.setDataRest(VIDEO_ADAPTER_LIST);
                                    videoListSelectPopWindow.showDownPopwindow(binding.grayLayout, true);
                                } else {
                                    Toast.makeText(GoodsPublishActivity.this, "最多选择五个视频", Toast.LENGTH_SHORT).show();
                                }
                            }

                            @Override
                            public void openVideo(VideoEntity url) {

                            }
                        });
                    } else if ("richtext".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getType())) {//富文本
                        //手机不支持编辑，请使用电脑后台编辑
                        if (addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal() == null) {
                            //外层布局
                            LinearLayout linearLayout = new LinearLayout(GoodsPublishActivity.this);
                            //加入父布局
                            pLinearLayout.addView(linearLayout);
                            //设置本层布局的背景颜色
                            linearLayout.setBackgroundColor(getResources().getColor(R.color.color_FAFAFA));
                            //设置垂直布局
                            linearLayout.setOrientation(LinearLayout.VERTICAL);
                            //标题
                            TextView tvTitle = new TextView(GoodsPublishActivity.this);
                            //加入当前父布局
                            linearLayout.addView(tvTitle);
                            tvTitle.setText(addLayoutEntityList.get(i).getSubColumns().get(j).getName());
                            tvTitle.setTextColor(ColorUtils.getColor(R.color.color_333333));
                            //得到标题控件的 LayoutParams
                            LinearLayout.LayoutParams textViewLayoutParams = (LinearLayout.LayoutParams) tvTitle.getLayoutParams();
                            //设置标题边距
                            textViewLayoutParams.topMargin = DensityUtils.dip2px(this, 10);
                            textViewLayoutParams.bottomMargin = DensityUtils.dip2px(this, 4);
                            textViewLayoutParams.leftMargin = DensityUtils.dip2px(this, 10);

                            //提示文字
                            TextView tvSubTitle = new TextView(GoodsPublishActivity.this);
                            //加入当前父布局
                            linearLayout.addView(tvSubTitle);
                            tvSubTitle.setText("(暂无数据,手机不支持编辑，请使用电脑后台编辑)");
                            tvSubTitle.setTextColor(ColorUtils.getColor(R.color.color_C0C4CC));
                            tvSubTitle.setTextSize(12f);
                            //得到标题控件的 LayoutParams
                            LinearLayout.LayoutParams tvSubTitleLayoutParams = (LinearLayout.LayoutParams) tvSubTitle.getLayoutParams();
                            //设置标题边距
                            tvSubTitleLayoutParams.bottomMargin = DensityUtils.dip2px(this, 10);
                            tvSubTitleLayoutParams.leftMargin = DensityUtils.dip2px(this, 10);
                        } else {
                            //外层布局
                            LinearLayout linearLayout = new LinearLayout(GoodsPublishActivity.this);
                            //加入父布局
                            pLinearLayout.addView(linearLayout);
                            //设置本层布局的背景颜色
                            linearLayout.setBackgroundColor(getResources().getColor(R.color.color_FAFAFA));
                            //设置垂直布局
                            linearLayout.setOrientation(LinearLayout.VERTICAL);
                            //标题
                            TextView tvTitle = new TextView(GoodsPublishActivity.this);
                            //加入当前父布局
                            linearLayout.addView(tvTitle);
                            tvTitle.setText(addLayoutEntityList.get(i).getSubColumns().get(j).getName());
                            tvTitle.setTextColor(ColorUtils.getColor(R.color.color_333333));
                            //得到标题控件的 LayoutParams
                            LinearLayout.LayoutParams textViewLayoutParams = (LinearLayout.LayoutParams) tvTitle.getLayoutParams();
                            //设置标题边距
                            textViewLayoutParams.topMargin = DensityUtils.dip2px(this, 10);
                            textViewLayoutParams.bottomMargin = DensityUtils.dip2px(this, 4);
                            textViewLayoutParams.leftMargin = DensityUtils.dip2px(this, 10);

                            //提示文字
                            TextView tvSubTitle = new TextView(GoodsPublishActivity.this);
                            //加入当前父布局
                            linearLayout.addView(tvSubTitle);
                            tvSubTitle.setText("(手机不支持编辑，请使用电脑后台编辑)");
                            tvSubTitle.setTextColor(ColorUtils.getColor(R.color.color_C0C4CC));
                            tvSubTitle.setTextSize(12f);
                            //得到标题控件的 LayoutParams
                            LinearLayout.LayoutParams tvSubTitleLayoutParams = (LinearLayout.LayoutParams) tvSubTitle.getLayoutParams();
                            //设置标题边距
                            tvSubTitleLayoutParams.bottomMargin = DensityUtils.dip2px(this, 10);
                            tvSubTitleLayoutParams.leftMargin = DensityUtils.dip2px(this, 10);

                            //WebView布局
                            WebView richTextWebView = new WebView(GoodsPublishActivity.this);
                            //加入父布局
                            linearLayout.addView(richTextWebView);
                            //得到标题控件的 LayoutParams
                            LinearLayout.LayoutParams webViewLayoutParams = (LinearLayout.LayoutParams) richTextWebView.getLayoutParams();
                            webViewLayoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
                            richTextWebView.loadDataWithBaseURL(null, setWebViewContent(addLayoutEntityList.get(i).getSubColumns().get(j).getTitleColumnVal()), "text/html", "UTF-8", null);
                            richTextWebView.getSettings().setJavaScriptEnabled(true);
                            richTextWebView.getSettings().setSupportZoom(false);
                            richTextWebView.getSettings().setBuiltInZoomControls(false);
                            richTextWebView.getSettings().setUseWideViewPort(true);
                            richTextWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
                            richTextWebView.getSettings().setLoadWithOverviewMode(true);
                            richTextWebView.setBackgroundColor(getResources().getColor(R.color.color_FAFAFA)); // 设置背景色
                            richTextWebView.requestLayout();
                        }

                        //添加底部线条
                        if (j != addLayoutEntityList.get(i).getSubColumns().size() - 1) {
                            TextView bottomLine = new TextView(GoodsPublishActivity.this);
                            pLinearLayout.addView(bottomLine);
                            bottomLine.setBackgroundColor(getResources().getColor(R.color.color_EDEDED));
                            //拿到bottomLine的LayoutParams
                            LinearLayout.LayoutParams bottomLineLayoutParams = (LinearLayout.LayoutParams) bottomLine.getLayoutParams();
                            bottomLineLayoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;//充满
                            bottomLineLayoutParams.height = 1;
                            bottomLineLayoutParams.rightMargin = DensityUtils.dip2px(this, 5);
                            bottomLineLayoutParams.leftMargin = DensityUtils.dip2px(this, 5);
                        }
                    }
                }
            }
        } else {
            binding.tvOther.setVisibility(View.GONE);
        }
    }

    /**
     * 适配image和table标签
     */
    private String setWebViewContent(String content) {
        String head = "<style type=\"text/css\"> img {" +
                "width:100%;" +//限定图片宽度填充屏幕
                "height:auto;" +//限定图片高度自动
                "}" +
                "body {" +
                "margin-right:15px;" +//限定网页中的文字右边距为15px(可根据实际需要进行行管屏幕适配操作)
                "margin-left:15px;" +//限定网页中的文字左边距为15px(可根据实际需要进行行管屏幕适配操作)
                "margin-top:15px;" +//限定网页中的文字上边距为15px(可根据实际需要进行行管屏幕适配操作)
                "font-size:38px;" +//限定网页中文字的大小为40px,请务必根据各种屏幕分辨率进行适配更改
                "word-wrap:break-word;" +//允许自动换行(汉字网页应该不需要这一属性,这个用来强制英文单词换行,类似于word/wps中的西文换行)
                "}" +
                "</style>";
        return "<html><header>" + head + "</header>" + content + "</html>";
    }

    /**
     * 拿到动态控件的数据
     */
    private void setOtherData() {
        if (addLayoutEntityList != null) {
            List<OtherInfo> otherInfoList = new ArrayList<>();
            otherInfoList.clear();
            for (int i = 0; i < addLayoutEntityList.size(); i++) {
                for (int j = 0; j < addLayoutEntityList.get(i).getSubColumns().size(); j++) {
                    int id = addLayoutEntityList.get(i).getSubColumns().get(j).getId();
                    if ("input".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getType())) {
                        OtherInfo otherInfo = new OtherInfo();
                        otherInfo.setId(addLayoutEntityList.get(i).getSubColumns().get(j).getId());
                        otherInfo.setTitleColumnVal(mPItv.get(id).getContent());
                        otherInfoList.add(otherInfo);
                    } else if ("textarea".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getType())) {
                        OtherInfo otherInfo = new OtherInfo();
                        otherInfo.setId(addLayoutEntityList.get(i).getSubColumns().get(j).getId());
                        otherInfo.setTitleColumnVal(mPTae.get(id).getEditContent());
                        otherInfoList.add(otherInfo);
                    } else if ("pic".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getType())) {
                        OtherInfo otherInfo = new OtherInfo();
                        otherInfo.setId(addLayoutEntityList.get(i).getSubColumns().get(j).getId());
                        if (mPUpUrl.get(id).size() != 0) {
                            otherInfo.setTitleColumnVal(new Gson().toJson(mPUpUrl.get(id)));
                        } else if (mPImgAdapter.get(id).getNetUrls().size() != 0) {
                            otherInfo.setTitleColumnVal(new Gson().toJson(mPImgAdapter.get(id).getNetUrls()));
                        } else {
                            otherInfo.setTitleColumnVal("");
                        }
                        otherInfoList.add(otherInfo);
                    } else if ("video".equals(addLayoutEntityList.get(i).getSubColumns().get(j).getType())) {
                        OtherInfo otherInfo = new OtherInfo();
                        otherInfo.setId(addLayoutEntityList.get(i).getSubColumns().get(j).getId());
                        if (mPVideoAdapter.get(id).getUrls().size() != 0) {
                            otherInfo.setTitleColumnVal(new Gson().toJson(mPVideoAdapter.get(id).getUrls()));
                        } else {
                            otherInfo.setTitleColumnVal("");
                        }

                        otherInfoList.add(otherInfo);
                    }
                }
            }
            if (isST) {
                viewModel.sTPublishEntity.get().setOtherInfos(otherInfoList);
            } else {
                viewModel.goodsPublishEntity.get().setOtherInfos(otherInfoList);
            }
        }
    }

    private void upAdapterImg(List<File> files, int position) {
        if (files.size() != 0) {
            mPUpUrl.get(position).clear();
            mPImageCount.put(position, files.size());
            viewModel.listAdapterUp(files.get(mPCurrentImgNum.get(position)), 0, mPCurrentImgNum.get(position) + 1, position);
        }
    }

    //图片循环单张上传
    public void listAdapterRefresh(String url, int type, int position) {
        mPUpUrl.get(position).add(url);
        if (mPCurrentImgNum.get(position) + 1 == mPImageCount.get(position)) {
            if (mPImgAdapter.get(position).getNetUrls() != null && mPImgAdapter.get(position).getNetUrls().size() != 0)
                for (int i = 0; i < mPImgAdapter.get(position).getNetUrls().size(); i++) {
                    mPUpUrl.get(position).add(i, mPImgAdapter.get(position).getNetUrls().get(i));
                }
        } else {
            int a = mPCurrentImgNum.get(position);
            a++;
            mPCurrentImgNum.put(position, a);
            viewModel.listAdapterUp(mPImgAdapter.get(position).getFileList().get(mPCurrentImgNum.get(position)), 0, mPCurrentImgNum.get(position) + 1, position);
        }
    }

    public void MoveToPosition(LinearLayoutManager manager, int n) {
        manager.scrollToPositionWithOffset(n, 0);
        manager.setStackFromEnd(true);
    }

    public void showServices(List<GoodsServicesEntity> data) {
        listService = data;
        if (data != null && data.size() > 0) {
            binding.tvChip.setVisibility(View.VISIBLE);
            binding.tvChip.setLabelNameColor(ColorUtils.getColor(R.color.color_tab_one));
            binding.tvChip.setContent("");
            List<GoodsPublishInfoEntity> serverInfoDTOS = new ArrayList<>();
            for (int m = 0; m < listService.size(); m++) {
                for (int n = 0; n < listService.get(m).getValue().size(); n++) {
                    for (int l = 0; l < listService.get(m).getValue().get(n).getValue().size(); l++) {
                        //组装数据到serverInfoDTOS字段下
                        GoodsPublishInfoEntity itemInfo = new GoodsPublishInfoEntity();
                        itemInfo.setServiceType(listService.get(m).getServiceType());
                        itemInfo.setServerName(listService.get(m).getValue().get(n).getValue().get(l).getServerName());
                        itemInfo.setAttributeId(listService.get(m).getValue().get(n).getValue().get(l).getAttributeId());
                        itemInfo.setAttributeName(listService.get(m).getValue().get(n).getValue().get(l).getAttributeName());
                        itemInfo.setChecked(listService.get(m).getValue().get(n).getValue().get(l).getChecked());
                        itemInfo.setCustomed(listService.get(m).getValue().get(n).getValue().get(l).getCustomed());
                        itemInfo.setId(listService.get(m).getValue().get(n).getValue().get(l).getId());
                        itemInfo.setSort(listService.get(m).getValue().get(n).getValue().get(l).getSort());
                        itemInfo.setServerName(listService.get(m).getValue().get(n).getValue().get(l).getServerName());
                        itemInfo.setDeleted(listService.get(m).getValue().get(n).getValue().get(l).getDeleted());
                        serverInfoDTOS.add(itemInfo);
                    }
                }
            }
            viewModel.sTPublishEntity.get().setServerInfoDTOS(serverInfoDTOS);
            viewModel.goodsPublishEntity.get().setServerInfoDTOS(serverInfoDTOS);
        } else {
            binding.tvChip.setVisibility(View.GONE);
            binding.tvChip.setLabelNameColor(ColorUtils.getColor(R.color.color_tab_one));
        }
    }
}